I coded this, which is working but I think there is a better way to do this.. I have a form where the user can check from checkboxes. For each checkbox I have multiple info that I want to send to my servlet, so I thought to create manually a JSON...
<input name="warehouse"
value="{ 'version':'<%=b.getVersion()%>',
'product':'<%=b.getProduct()%>',
'productionDate':'<%=b.getProductionDate()%>',
'order':'<%=b.getOrder()%>'
}"
type="checkbox">
Then in my servlet, I read the String
String[] product = request.getParameterValues("warehouse");
I replace the "
with '
product.replace("'","\"");
and then I convert the String in JSON
ObjectMapper mapper = new ObjectMapper();
Box box = mapper.readValue(product, Box.class);
Is there a better way than the above to send the all these info to my servlet?
Aucun commentaire:
Enregistrer un commentaire