eclipse vs tomcat部署 - 项目在eclipse中运行时导出的war(部分)失败 [英] eclipse vs tomcat deployment - exported war (partially) fails while the project runs in eclipse
问题描述
右键单击> 导出战争>将其转储到$ CATALINA_HOME / webapps>都正常工作(已解压缩) EXCEPT
-
我的自定义标签 - 我有一个
WEB-INF \Functions.tld
文件显然没有读取。自动生成的eclipseserver.xml
(在Servers
项目中)和默认Tomcatserver.xml
是行:<上下文docBase =ted2012路径=/ ted2012
reloadable =truesource =org.eclipse.jst.jee.server:ted2012/>
code>是WTP特定的属性。
我设法解决了 - 请参阅我的答案
- Tomcat无法正确获取Url - 请参阅我的answer 。
问题:
- (未解决)为什么Tomcat不能正确解码Url - 而eclipse则?失败在哪里?看到我的具体对于这个问题,关于调用堆栈的详细信息以及Tomcat在哪里失败
- 为什么tomcat在eclipse中没有看到第一个位置?为什么我必须编辑
web.xml
? (在我的答案中,应该是另一个问题)
代码在 github - 在文件INSTRUCTIONS.txt中有详细的说明来设置项目并重现我下面回答的错误。
Tomcat 7.0.32,eclipse 4.2,java 1.7.9
正确解码URI ,您需要在Tomcat中使用URIEncoding连接器属性:
<连接器... URIEncoding =UTF-8... / >
看到我的咆哮 https://stackoverflow.com/a/15587140/995876
所以它不是普通的代码,你需要在应用程序服务器配置或使用默认为UTF-8的应用程序服务器。没有办法从代码中解决这个问题。
删除 decodeRequest
,从不使用 new String / getBytes
without explicit encoding argument。
替代。
如果您无法编辑服务器连接器配置,您可以通过将编码明确提供给 new String
:
public static String decodeRequest(String parameter){
return new String(parameter.getBytes(iso-8859-1 ),UTF-8);
}
I have a webapp in eclipse juno - when I hit Run on server runs fine - either inside eclipse's browser (I am on windows) or in FF.
Right click > export war > dump this into $CATALINA_HOME/webapps > all is working fine (got unpacked alright) EXCEPT
my custom tags - I had a
WEB-INF\functions.tld
file which is apparently not read. The only difference between the auto-generated eclipseserver.xml
(inServers
project) and the default Tomcatserver.xml
was the line :<Context docBase="ted2012" path="/ted2012" reloadable="true"source="org.eclipse.jst.jee.server:ted2012"/>
source
being a WTP specific attribute.
This I managed to solve - see my answer
- Tomcat won't get the Url correctly through - see the pics in my answer.
Questions :
- (Unsolved) Why Tomcat does not decode the Url correctly - while eclipse does ? Where is the failure ? Do see my specific question for this for extensive details on the call stack and where exactly tomcat fails
- Why did not tomcat see the tld in the first place while eclipse did ? Why did I have to edit the
web.xml
? (worked around in my answer, should be another question)
The code is in github - in the file INSTRUCTIONS.txt there are detailed instructions to set the project up and reproduce the bug pictured in my answer below.
Tomcat 7.0.32, eclipse 4.2, java 1.7.9
For decoding URIs correctly, you need URIEncoding connector attribute in Tomcat:
<connector ... URIEncoding="UTF-8" ... />
See my rant https://stackoverflow.com/a/15587140/995876
So it doesn't come with normal code, you need it in the application server configuration separately or use an application server that defaults to UTF-8. There is no way to affect this from code unfortunately.
Drop the decodeRequest
and never use new String/getBytes
without explicit encoding argument.
Alternative.
If you can't edit the server connector configuration, you can fix your code by providing the encoding explicitly to new String
:
public static String decodeRequest(String parameter) {
return new String(parameter.getBytes("iso-8859-1"), "UTF-8");
}
这篇关于eclipse vs tomcat部署 - 项目在eclipse中运行时导出的war(部分)失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!