0
JSONArrayをSpringのモデル属性に追加し、ModelAndView Controllerから戻したいとします。以下のようにすることはできません。助けを求めるありがとう!spring modelandview controllerのモデル属性にJSONArrayを設定するにはどうすればいいですか?
@RequestMapping(value = "/sample.htm", method = RequestMethod.GET)
public ModelAndView seatRequest(ModelMap model,
HttpServletRequest request,HttpServletResponse response, HttpSession session) throws JSONException, JsonProcessingException {
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject = new JSONObject();
jsonObject.put("0", "val0");
jsonObject.put("1", "val1");
jsonObject.put("2", "val2");
jsonArray.put(jsonObject);
model.addAttribute("jsonData",jsonArray.toString());
return new ModelAndView("sample");