eclipse vs tomcat 部署 - 当项目在 eclipse 中运行时,导出的战争(部分)失败 [英] eclipse vs tomcat deployment - exported war (partially) fails while the project runs in eclipse

查看:33
本文介绍了eclipse vs tomcat 部署 - 当项目在 eclipse 中运行时,导出的战争(部分)失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 eclipse juno 中有一个 web 应用程序 - 当我点击 Run on server 运行良好 - 无论是在 eclipse 的浏览器中(我在 Windows 上)还是在 FF 中.

右键单击 > export war > 将其转储到 $CATALINA_HOME/webapps > 一切正常(解压好了)EXCEPT >

  • 我的自定义标签 - 我有一个 WEB-INFfunctions.tld 文件,它显然没有被读取.自动生成的 eclipse server.xml(在 Servers 项目中)和默认的 Tomcat server.xml 之间的唯一区别是:

source 是 WTP 特定的属性.
我设法解决了这个问题 - 请参阅我的答案

  • Tomcat 无法正确获取 URL - 请参阅我的答案中的图片.

问题:

  1. (未解决)为什么 Tomcat 不能正确解码 Url - 而 eclipse 可以?失败在哪里?请参阅我的特定 对此的问题有关调用堆栈的详细信息以及tomcat究竟失败的地方
  2. 为什么 tomcat 一开始没有看到 tld,而 eclipse 却看到了?为什么我必须编辑 web.xml ?(在我的回答中解决,应该是另一个问题)

代码在 github - 在文件 INSTRUCTIONS.txt 中有详细的说明来设置投射并重现下面我的答案中所示的错误.

Tomcat 7.0.32、eclipse 4.2、java 1.7.9

解决方案

为了正确解码 URI,您需要 Tomcat 中的 URIEncoding 连接器属性:

见我的咆哮 https://stackoverflow.com/a/15587140/995876

所以它没有附带普通代码,您需要在应用服务器配置中单独使用它或者使用默认为UTF-8的应用服务器.不幸的是,没有办法通过代码来影响这一点.

删除 decodeRequest 并且不要在没有明确编码参数的情况下使用 new String/getBytes.

<小时>

替代.

如果您无法编辑服务器连接器配置,您可以通过将编码显式提供给 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-INFfunctions.tld file which is apparently not read. The only difference between the auto-generated eclipse server.xml (in Servers project) and the default Tomcat server.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 :

  1. (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
  2. 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 中运行时,导出的战争(部分)失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆