jsp编码:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
_<form action="DownLoadServlet" method="get">
<table>
<caption>下载文件</caption>
<tr>
<td>下载文件名称:</td>
<td><input type="text" name="downloadname"/>**//request取值**
</td>
</tr>
<tr><td><input type="submit" value="提交"></td></tr>
</table>
</form>_
servlet代码:
request.setCharacterEncoding("UTF-8");//这个设了有什么用?
response.setContentType("UTF-8");//这个设了有什么用?
String name = request.getParameter("downloadname");//jsp都设置编码格式了为什么还是乱码!!!!
System.out.println(name);
name = new String(name.getBytes("ISO-8859-1"), "UTF-8");
System.out.println(name);
显示界面:
???
你
我恨utf-8,我恨utf-8,我恨utf-8
能解释一下一般转码的过程吗?我真是讨厌utf-8