Tomcat默认安装时,是8080端口。这时,要使Tomcat支持“UTF-8”的中文地址,只需要在server.xml文件中,将8080端口的<connector>标签设置成URIEncoding="UTF-8":
<
Connector
port
="8080"
URIEncoding
="UTF-8"
/>
当Tomcat用JK与Apache集成时,用works.properties文件来配置Apache和tomcat连接时使用的一些参数。其中包括Apache要使用的Tomcat端口:
worker
.
list
=
ajp13
worker . ajp13 . port = 8009
# 本机,若上面Tomcat主机不为localhost,作相应修改
worker . ajp13 . host = 192.168 . 1.5
# 类型
worker . ajp13 . type = ajp13
# 代理数,不用修改
worker . ajp13 . lbfactor = 1
worker . ajp13 . port = 8009
# 本机,若上面Tomcat主机不为localhost,作相应修改
worker . ajp13 . host = 192.168 . 1.5
# 类型
worker . ajp13 . type = ajp13
# 代理数,不用修改
worker . ajp13 . lbfactor = 1
文件中“rker.ajp13.port=8009”就是用来设置Apache要连接的Tomcat端口。因此,Apache和Tomcat集成后,要使服务器支持UTF-8的中文地址,应该设置8009端口的<connector>标签:
<
Connector
port
="8009"
URIEncoding
="UTF-8"
/>