用SpringMVC的responseBody的标签来将数据转成json格式,然后给app使用
代码如下:
@RequestMapping(value = "/jsontest")
@ResponseBody
public Map<String, User> getjsopn() {
User user=new User(1,"xuweijei","xuwiejei","xwj","nan","22","zhuhai");
String[] arrays=new String[]{"a","b","c"};
user.setArrays(arrays);
Map<String,User>map=new HashMap<String, User>();
map.put("user",user);
return map;
}
打开浏览器后显示结果如下:
SpringMVC还有其他方法可以实现,待日后再完善补充这篇博客