Where does Tomcat append / to directory paths?

拟墨画扇 提交于 2019-11-30 20:47:44

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

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.

The Eclipse debugger learnt me that the redirect happens in line 504 of CoyoteAdapter class, almost in the end of the postParseRequest() method.

    // Possible redirect
    MessageBytes redirectPathMB = request.getMappingData().redirectPath;
    if (!redirectPathMB.isNull()) {
        // ...
        response.sendRedirect(redirectPath); // <--- Here.
        return false;
    }

Tomcat 6.0.20 btw.

Update: actually, the redirectPath is indeed filled by the Mapper as mentioned in @Henning's answer, indeed in the internalMapWrapper() method. Checkout the source code here.

    if(mappingData.wrapper == null && noServletPath) {
        // The path is empty, redirect to "/"
        mappingData.redirectPath.setChars
            (path.getBuffer(), pathOffset, pathEnd);
        path.setEnd(pathEnd - 1);
        return;
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!