Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我打开
http://localhost:8080/test.jsp?document=ý
而这个jsp
<%@ page language="java" pageEncoding="UTF-8" %> <% request.setCharacterEncoding("UTF-8"); String d = request.getParameter("document");
它在调试器中给了我 d=ý 。我怎样才能得到正确的字母ý?
假设您使用的是 Tomcat,您仍然需要告诉您的 servlet 容器对 URI 使用 UTF8。在 Tomcats 配置目录中编辑 server.xml 中的连接器。
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" URIEncoding="UTF-8" />
最后一行很重要。
我建议阅读 Tomcats 网站的字符编码部分:
http://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q8