@ResponseBody @RequestMapping(value = "/list", method = {RequestMethod.POST, RequestMethod.GET}) public void getProjectList(HttpServletRequest request, HttpServletResponse response, Model model) throws IOException { JSONObject beanJSON = new JSONObject(); beanJSON.put("user", "张三"); beanJSON.put("time", "2000-1-1"); beanJSON.put("content", "hello word!");response.getWriter().print(beanJSON); // 输出
}
<script type="text/javascript"> var tt=eval("(" + resultText + ")"); //resultText 为ajax返回值, alert(tt.user); alert(tt.time); alert(tt.content);</script>
json数据传递
最新推荐文章于 2021-06-04 18:17:22 发布