字符编码

<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

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值