jsp乱码问题

java中文乱码

http://www.cnblogs.com/yechensi/archive/2009/09/08/1562208.html


解决乱码问题一:

js--

var url = "/Prj2-1struts/AJAXServer?name=" +
encodeURI($("#name").val());

servlet--

String name = new String(reqest.getParameter("name").getBytes("ISO-8859-1"),"UTF-8"); //由服务器决定是否为"ISO-8859-1"


解决乱码问题二:

js--

var url = "/Prj2-1struts/AJAXServer?name=" +
encodeURI(encodeURI($("#name").val()));

servlet--

String name = req.getParameter("name");
name = URLDecoder.decode(name, "UTF-8");




你可能感兴趣的:(jsp)