解决request.getParameter()中文乱码的问题

jsp页面中 用click事件调用js 此时的页面编码要用UTF-8
<script language="javascript">
location.href=encodeURI(encodeURI("test.do?para=测试");
<script >
在jsp页面中还可以用
<a href="test.do?para=<%=java.net.URLEncoder.encode("测试","UTF-8")%>">测试</a>

Servlet中用decode解码
String para= request.getParameter("para");
para = java.net.URLDecoder.decode(strname , "UTF-8");

String para =new String(request.getParameter("para").getBytes("iso-8859-1"),"UTF-8");

你可能感兴趣的:(java,.net,jsp,servlet)