function saveCommentTemplate() { $.ajax({ cache : false, type:‘get‘, dataType:‘json‘, url:‘comment/insert‘, contentType:‘application/json;charset=UTF-8‘, data:{name:encodeURI($("#name").val()), content:encodeURI($("#content").val())}, success:function(data){ alert("ok") }, error: function() { alert("error") } }); $("#bottom").hide(); }
@RequestMapping(value = "insert") @ResponseBody public void insert(@RequestParam("name") String name,@RequestParam("content")String content) throws UnsupportedEncodingException { name=URLDecoder.decode(name,"UTF-8"); content=URLDecoder.decode(content,"UTF-8"); commentTemplateService.saveCommentTemplate(name,content); }
原文:http://www.cnblogs.com/dscs/p/5740425.html