页面设置
jsp页面设置为utf-8
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
html页面的
<meta http-equiv="content-type" content="text/html; charset=utf-8">
ajax添加
scriptCharset:"utf-8"
传参方式
1、
data:{name:a}
这种传参方式,后台只需response.setContentType("text/html;charset=utf-8");
2、
url:text?name=a
这种传参方式
需要改成url:text?name=encodeURI(encodeURI(a))
后台添加response.setContentType("text/html;charset=utf-8");
后台接收数据进行转换name=URLDecoder.decode(name,"utf-8");