数据传递之前,先对中文进行编码,如下红色字体:
function saveCommentTemplate()
{
$.ajax({
cache : false,
type:'get',
dataType:'json',
url:'comment/insert',
contentType:'application/json;charset=UTF-8',
data:{name: }, 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= content= commentTemplateService.saveCommentTemplate(name,content);
}