如何让 tomcat 支持中文 url
目前的情况是:
页面编码采用utf-8,有一个filter过滤所有url
<filter>
<filter-name> Set Character Encoding </filter-name>
<filter-class> com.cjw.news.filter.EncodingFilter </filter-class>
<init-param>
<param-name> encoding </param-name>
<param-value> UTF-8 </param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name> Set Character Encoding </filter-name>
<url-pattern> /* </url-pattern>
</filter-mapping>
需求变动,需要有中文url。怎么才能让tomcat识别中文url呢?
前面的不能改动
------解决方案--------------------将启动tomcat进程的用户的编码设置为zh_CN.GB18030,这样可以保证Tomcat服务器正确访问文件系统的中文路径的文件
修改Tomcat配置,指定请求解码字符集(URIEncoding= "UTF-8 "),那么,IE如果用UTF-8发送URL请求的话是可以正确访问到中文路径的内容的;
<Connector port= "8080 " maxHttpHeaderSize= "8192 "
maxThreads= "150 " minSpareThreads= "25 " maxSpareThreads= "75 "
enableLookups= "false " redirectPort= "8443 " acceptCount= "100 "
connectionTimeout= "20000 " disableUploadTimeout= "true " URIEncoding= "utf-8 " />