关于servlet中中文乱码的解决方法

xiaoxiao2022-06-12  26

1、在response中写<meta http-equiv="content-style-type" content="text/html; charset=GB2312"> 2、使用new String(para.getBytes("iso-8859-1"), "gb2312") 3、 String lPara = "你好"; lPara = java.net.URLEncoder.encode(new String(lPara.getBytes("GBK"), "iso8859-1")); <a href="yourServlet?Para=<%=lPara%>">Test</a> ... yourServlet: String lPara = request.getParameter("Para"); 4、在得到变量的值之前(request.getParameter(...)),加一句 request.setCharacterEncoding("gb2312");
转载请注明原文地址: https://www.6miu.com/read-4933591.html

最新回复(0)