以下是Spring MVC 一个Controller下的方法,返回的是Json
1: @ResponseBody
2:返回 Map<String,Object>
以下是代码:
@RequestMapping("/checkUser") @ResponseBody public Map<String,Object> checkUser( String name,String param, HttpServletRequest request){ Map<String,Object> map=new HashMap<String,Object>(); List<AgencyEntity> agencyList=agencyService.findByProperty(AgencyEntity.class, "account", name); if(agencyList.size()!=0){ map.put("status", "y"); map.put("info","账号已经存在!" ); }else{ map.put("status", "n"); map.put("info", "账号可以使用!"); } return map; }
Spring MVC Json相关问题,布布扣,bubuko.com
原文地址:http://blog.csdn.net/qq673318522/article/details/38663137