字符编码

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

 

 

Due to the lack of a standard, different browers took different approaches to the character encoding used. Some use the encoding of the page and some use UTF-8. Some drafts were prepared by various standards bodies suggesting that UTF-8 would become the standard encoding. Older versions of jetty (eg 4.0.x series) used UTF-8 as the default in anticipation of a standard being adopted. As a standard was not forthcoming, jetty-4.1.x reverted to a default encoding of ISO-8859-1.

 

The W3C organization's HTML standard now recommends the use of UTF-8: http://www.w3.org/TR/html40/appendix/notes.html#non-ascii-chars and accordingly jetty-6 series uses a default of UTF-8.

 

If UTF-8 is not correct for your environment, you may use one of two jetty-specific methods to set the charset encoding of the query string in GET requests:

 

  1. call Request.setQueryEncoding(String) before reading any of the content or params.
  2. set the system property org.mortbay.util.URI.charset to the encoding you want to use.

在jetty中设置:

官方文档:http://docs.codehaus.org/display/JETTY/International+Characters+and+Character+Encodings

在jetty6中是:

  1. call Request.setQueryEncoding(String) before reading any of the content or params.
  2. set the system property org.mortbay.util.URI.charset to the encoding you want to use.

通常用方法2较好可以不用侵入代码,只需要在启动jetty脚本加上:-Dorg.mortbay.util.URI.charset=utf-8

 

$JAVA_HOME/bin/java -Dorg.mortbay.util.URI.charset=utf-8 -jar $JETTY_HOME/start.jar -Djetty.home=$JETTY_HOME $JETTY_ARGS

 

jetty7中脚本片断如下:

JETTY_URI_ENCODE=-Dorg.eclipse.jetty.util.URI.charset=UTF-8

$JAVA_HOME/bin/java $JAVA_OPTS $JETTY_URI_ENCODE -jar $JETTY_HOME/start.jar -Djetty.home=$JETTY_HOME $JETTY_ARGS

 

你可能感兴趣的:(tomcat jetty)