起初的错误做法:
document.forms['form_main'].action = "tsaServiceAdd.jsp?notice=修改TSA服务";
结果在tsaServiceAdd.jsp页面中通过 request.getParameter(notice);获取到对应的参数后,发现获取到的值乱码。
正确的做法:
将要传输的中文数据进行两次encodeURIComponent编码,将编码后的数据进行传输
var s = encodeURIComponent(encodeURIComponent(修改TSA服务));
document.forms['form_main'].action = "tsaServiceAdd.jsp?notice="+s;
然后在接收数据的jsp页面中,将接收到两次编码后的数据,进行两次解码便可以获得对应的中文数据
String notice = request.getParameter(notice);
String information = (URLDecoder.decode(notice, utf-8));
打印出information,发现正确获得传输前的中文信息