ajax post 提交中文java后台获取参数出现乱码解决方法

代码示例:

js端;用encodeURI()两次转码

var subject=encodeURI(encodeURI($("#subject").val()));
var content=encodeURI(encodeURI($(".summernote").code()));

java端;用URLDecoder.decode()方法解码

String subject=this.getRequest().getParameter("subject");
String content=this.getRequest().getParameter("content");

subject=URLDecoder.decode(subject, "UTF-8");
content=URLDecoder.decode(content, "UTF-8");

你可能感兴趣的:(ajax post 提交中文java后台获取参数出现乱码解决方法)