Mr_*_*s_D 3 eclipse unicode tomcat java-ee servlet-3.0
我在eclipse juno中有一个webapp - 当我在服务器上运行时运行正常 - 在eclipse的浏览器(我在Windows上)或在FF中.
右键单击> 导出war >将其转储到$ CATALINA_HOME/webapps>一切正常(解压缩好了)EXCEPT
我的自定义标签 - 我有一个WEB-INF\functions.tld显然没有读过的文件.自动生成的eclipse server.xml(在Servers项目中)和默认的Tomcat 之间的唯一区别server.xml是:
<Context docBase="ted2012" path="/ted2012"
reloadable="true"source="org.eclipse.jst.jee.server:ted2012"/>
Run Code Online (Sandbox Code Playgroud)source是WTP特定属性.
我设法解决了 - 看我的答案
问题:
web.xml?(在我的回答中解决,应该是另一个问题)代码在github中 - 在文件INSTRUCTIONS.txt中有详细的说明来设置项目并重现我在下面的答案中描绘的错误.
Tomcat 7.0.32,eclipse 4.2,java 1.7.9
要正确解码URI,您需要Tomcat中的URIEncoding连接器属性:
<connector ... URIEncoding="UTF-8" ... />
Run Code Online (Sandbox Code Playgroud)
请参阅我的咆哮/sf/answers/1091099831/
因此,它没有正常的代码,您需要单独在应用程序服务器配置中使用它,或者使用默认为UTF-8的应用程序服务器.遗憾的是,无法从代码中影响这一点.
删除decodeRequest并且不使用new String/getBytes没有显式编码参数.
另类.
如果您无法编辑服务器连接器配置,则可以通过明确提供编码来修复代码new String:
public static String decodeRequest(String parameter) {
return new String(parameter.getBytes("iso-8859-1"), "UTF-8");
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1312 次 |
| 最近记录: |