两处加上URIEncoding="UTF-8" 如下:
<Connector
port="8080" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="UTF-8"/>
另一处:这一处很关键,因为如果与apache结合时,端口转发时也要编码成UTF-8
<Connector port="8009"
enableLookups="false" redirectPort="8443" protocol="AJP/1.3" URIEncoding="UTF-8" />
2)在URLEncoder.encode中指明用UTF-8编码。
<a href=tag.jsp?tag=<%=URLEncoder.encode(blog.getTags(),"UTF-8")%>><strong><font color=red><%=blog.getTags() %>
解码时直接用
java.net.URLDecoder.decode(request.getParameter("tag"));即可解决乱码问题!