---
title: "tomcat的URIEncoding的作用"
author: "iblike"
date: "2011-02-17T17:01:12Z"
tags: ["IIS", "JSP", "Servlet", "Tomcat", "XML"]
categories: ["Web前端"]
slug: "tomcat-uriencoding"
draft: false
lastmod: "2011-02-17T17:01:12Z"
id: 909094
url: "https://iblike.iteye.com/blog/909094"
---

tomcat5中，为了保证get数据采用UTF8编码，在server.xml中进行了如下设置：

```
<Connector port="8080" maxThreads="150" minSpareThreads="25" 
maxSpareThreads="75" enableLookups="false" redirectPort="8443" 
acceptCount="100" debug="99" connectionTimeout="20000" 
disableUploadTimeout="true" URIEncoding="UTF-8"/>
```

   
这里指定了get时候的数据编码。但是，当使用IIS作为webserver转发servlet/jsp请求给Tomcat时候，这个设置却失效了。其实原因很简单：IIS是通过AJP协议，把请求转发到Tomcat监听的8009端口上的，所以这里针对8080的设置自然就无效了。正确的方法是进行下面的设置：

```
<Connector port="8009" enableLookups="false" redirectPort="8443" 
debug="0" protocol="AJP/1.3" URIEncoding="UTF-8"/>
```