`

@ResponseBody的使用

 
阅读更多

@ResponseBody注解的用法 ,直接返回json对象



public Map<String, String> existGroupName(@RequestParam String groupName) {
  String result = "";
  Map<String, String> map = new HashMap<String, String>();
  FaxContactPersonGroup group = faxContactPersonGroupService
    .existGroupName(groupName);
  if (group != null) {
   result = "该组名已经存在,请重新输入";
  }
  map.put("data", result);
  return map;
}

$.post("<%=request.getContextPath()%>/fax/group/exist.html",
        {groupName:name},
        function(data){
         if(data.data!==''){
          alert(data.data);
          $("#groupName1").focus();
          return false;
         }else{
          return true;
         }
        });

普通用法:

this.write(response, JsonHelper.JSON_Bean2String(resultMap));



   $("#addGroupForm").form('submit',{
      success : function(data) {
       var data = $.parseJSON(data);//json对象
       var model = data.model;
        });

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics