2011-04-07 42 views
0

我部署example.war到Tomcat 6.0.32(最新在寫作時),以及Web應用程序部署包含以下內容:提升Web應用程序具有目錄和資源具有相同的名稱,但提供302

$ find example | egrep -v "WEB-INF/lib|WEB-INF/classes" 
example 
example/_items.html 
example/_share_link.html 
example/all_items.html 
example/images 
example/images/ajax-loader.gif 
example/index.html 
example/item 
example/item/star.html 
example/item.html 
example/js 
example/js/c-jquery-1.4.2.js 
example/js/c-jquery-ui-1.8.2.js 
example/js/jquery-1.4.2.js 
example/js/jquery-1.4.4.min.js 
example/js/jquery-ui-1.8.2.js 
example/js/jquery-ui-1.8.8.custom.min.js 
example/js/jquery.blockUI.js 
example/META-INF 
example/META-INF/MANIFEST.MF 
example/search.html 
example/static 
example/static/index.html 
example/templates-hidden 
example/templates-hidden/default.html 
example/templates-hidden/wizard-all.html 
example/WEB-INF 
example/WEB-INF/web.xml 

特別注:

example/item 
example/item/star.html 
example/item.html 

我嘗試,並要求上述資源:

$ telnet localhost 8080 
Trying ::1... 
Connected to localhost. 
Escape character is '^]'. 
GET /example/item HTTP/1.0 

HTTP/1.1 302 Moved Temporarily 
Server: Apache-Coyote/1.1 
Location: http://localhost:8080/example/item/ 
Date: Thu, 07 Apr 2011 08:24:39 GMT 
Connection: close 

Connection closed by foreign host. 

服務器告訴我試試/example/item/

$ telnet localhost 8080 
Trying ::1... 
Connected to localhost. 
Escape character is '^]'. 
GET /example/item/ HTTP/1.0 

HTTP/1.1 404 Not Found 
Server: Apache-Coyote/1.1 
Set-Cookie: JSESSIONID=6D97AD3A8F77697146163946B1BBBB64; Path=/example 
Expires: Thu, 7 Apr 2011 08:24:58 UTC 
Cache-Control: no-cache, private, no-store 
Pragma: no-cache 
Date: Thu, 07 Apr 2011 08:24:58 GMT 
X-Lift-Version: 2.3 
Content-Type: text/html;charset=utf-8 
Content-Length: 106 
Connection: close 

<!DOCTYPE html> 
<html> <body>The Requested URL /example/item/ was not found on this server</body> </html> 
    Connection closed by foreign host. 

這不是我所期望的。第一個請求/example/item(沒有斜線)應該可以工作 - 在這一點上,Lift Web框架接管並渲染我的物品,使用star.html作爲模板。這對於Jetty 6.1.22和Resin 4.0.16非常適用,但不適用於Tomcat。

是否有一些特殊配置我錯過了?在這種情況下,servlet規範中是否存在表示正確行爲的內容?

我使用的示例代碼可以在這裏找到: https://github.com/dpp/simply_lift/tree/master/samples/shopwithme

我提出原來的問題在這裏: https://groups.google.com/forum/?fromgroups#!topic/liftweb/7QlFud1ieOU

注意這個問題是不是電梯或其渲染管線 - 這是關於Tomcat,以及它的行爲與Jetty和Resin不同的原因。


UPDATE:這是典型的「斜線」問題,bug報告已經在這裏提交:https://issues.apache.org/bugzilla/show_bug.cgi?id=32424

回答

2

有人回答了這個,但問題是措辭完全不同,這是爲什麼我要離開我的問題是,是(對於那些誰使用不同的搜索條件的用戶):

Where does Tomcat append/to directory paths?

概括地說,看到這個類:

http://svn.apache.org/repos/asf/tomcat/tc6.0.x/tags/TOMCAT_6_0_26/java/org/apache/tomcat/util/http/mapper/Mapper.java

...然後找到一個註釋在類的細節「默認servlet」 - 這就是所謂的「第7條」,而根據衆多,是一個錯誤:https://issues.apache.org/bugzilla/show_bug.cgi?id=32424

它將留不固定在Tomcat中可預見的,根據評論的開發商之一:

行爲未指定任何地方 ,但這個想法是,在 情況下,物理文件夾或根 的上下文中,尾部'/'不是 相關。因爲這會導致反覆發作 路徑解析問題(這使 的servlet像我們默認的servlet 不必要的更復雜),我們總是 目前該servlet在所有情況下,訓練 「/」。它也是最有效的,所以這就是目前使用的 實施方案 。

我很後悔它會阻止你從 使用Tomcat,但沒有什麼 我會在這裏改變。

相關問題