- 返回JSON对象,我们就需要用到@ResponseBody注解,如果接收JSON数据封装成JavaBean的话,我们就需要用到@requestBody注解。随后在配置文件上创建对应的bean即可。
- 一、通过json数据传输
二、通过url数据传输
$("#submit_bt").click(function(){ var data = "func_name=" + $("#func_name").val() + "&link_url=" + $("#link_url").val() +"&is_valid=" + $("#is_valid option:selected").val() +"&parent_id=" + $("#parent_id").val(); $.ajax({ type:'post', url:'${ctx}/admin/funcion/add', dataType : 'json', data: data, contentType: "application/x-www-form-urlencoded; charset=utf-8", success:function(data){ if ;0") { window.loca;${ctx}/admin/funcion/list?page_size=10&father_id=${father_id}"; } else { aler); } }, error: function(textStatus) { alert(textStatus); } }); }); @RequestMapping(value = "/admin/funcion/add") @ResponseBody @Authority) public RetInfo addFunction(HttpServletRequest request, @Valid TsJzFuncion function, BindingResult result) { RetInfo retInfo = new RetInfo(); if ()) { List<FieldError> err = re(); FieldError fe = err.get(0); re("1"); re()); } else { HttpSession session = reque(false); TsJzAdmin tsJzAdmin = (TsJzAdmin) ); retInfo = (function, tsJzAdmin); } return retInfo;