We're developing a webpage using Spring MVC. In one of our controllers we hava a HashMap which we should send to our jsp like:
ModelAndView model = sisoController.getGenericModelAndView(request);
HashMap<String, boolean> hashMap = new HashMap<String, boolean>();
hashMap.put("name", true);
hashMap.put("surname", false); //... and so on
model.addObject("operationFields", hashMap);
model.setViewName("createOperation.html");
return model;
Now, we need to access this hashMap in our jsp page, inside the javascript section when document.ready. Something like:
var operationFields= ${operationFields};
$.each(operationFields, function(key, value) {
console.log(key + ": " + value);
});
But this responds with the following error:
SyntaxError: missing : after property id
var operationFields= {name=true, surname=false};
How could we access the hashMap?