Tomcat在哪里附加/到目录路径? [英] Where does Tomcat append / to directory paths?

查看:116
本文介绍了Tomcat在哪里附加/到目录路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我的Tomcat webapps目录如下所示:

Suppose my Tomcat webapps directory looks like this:

webapps/
webapps/fooapp/
webapps/fooapp/WEB-INF/
webapps/fooapp/WEB-INF/web.xml
webapps/fooapp/bardir/

当我对 / fooapp / bardir 发出GET请求时,Tomcat发现webapps / fooapp / bardir是一个目录并发送将302返回 / fooapp / bardir / (最后用斜杠)。

When I make a GET request for /fooapp/bardir, Tomcat sees that webapps/fooapp/bardir is a directory and sends back a 302 to /fooapp/bardir/ (with a slash at the end).

这是我的问题: Tomcat源代码中的会发生这种情况吗?(我正在研究6.0.x,但任何版本的正确答案都是一个很好的起点。)

Here is my question: Where in the Tomcat source code does this take place? (I'm looking at 6.0.x but a correct answer for any version would be a great starting point.)

我能在这个主题上找到的唯一参考资料是 Catalina Functional Specifications ,其中说明了默认Servlet:

The only reference material I can find on this subject is in the Catalina Functional Specifications which states, regarding the Default Servlet:


在此se处理的每个HTTP GET请求上rvlet,应执行以下处理:

On each HTTP GET request processed by this servlet, the following processing shall be performed:

[...]


  • 如果请求的资源是目录:


    • 如果请求路径不以/结尾,则重定向到附加了/的相应路径欢迎文件中的相对引用已正确解析。

    但是,此功能似乎不在org.apache.catalina.servlets.DefaultServlet中;或者至少,它并不是唯一的:如果我将web.xml中的默认servlet替换为 servlet-class不存在的servlet,则目录路径仍会返回302 添加斜杠,而其他每个请求都会按预期返回错误。

    However, this functionality does not appear to be in org.apache.catalina.servlets.DefaultServlet; or at least, it's not there exclusively: if I replace the default servlet in web.xml with a servlet whose servlet-class does not exist, directory paths still come back 302 to add the slash, while every other request comes back with an error as expected.

    推荐答案

    认为它发生在 org.apache.tomcat.util.http.mapper.Mapper ,即在 internalMapWrapper(Context,CharChunk,MappingData)方法。

    I think it happens in org.apache.tomcat.util.http.mapper.Mapper, namely in the internalMapWrapper (Context, CharChunk, MappingData) method.

    但不幸的是我不太确定 - 也许这真的是一个更适合 tomcat-users 邮件列表。很抱歉没有更好的答案。

    But unfortunately I'm not really sure -- maybe this really is a question better suited for the tomcat-users mailing list. Sorry for not having a better answer.

    这篇关于Tomcat在哪里附加/到目录路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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