码迷,mamicode.com
首页 > 其他好文 > 详细

Tomcat, pathinfo, and servlets

时间:2015-06-18 21:39:14      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:

 

So today I learned that you can‘t just access PATH_INFO (pathinfo) information from a servlet when you‘re using Tomcat (at least not Tomcat 3.2.4 running under Apache). I can access the PATH_INFO information okay under Tomcat running standalone on my PC, but for some reason the same config did not work properly using Tomcat under Apache. (I‘ll investigate this more in the future.)

Specifically, for me to be able to access PATH_INFO (PathInfo) information in a servlet, I had to add this servlet mapping information to my web.xml file:

    <servlet-mapping>
        <servlet-name>
            Content
        </servlet-name>
        <url-pattern>
            /Content/*
        </url-pattern>
    </servlet-mapping>

  

The /Content/* is the key. When I just had /Content as the url-pattern like I normally would, I kept getting a 404 error any time I pre-pended anything to the end of my servlet call (for instance, when I tried to hit a URL like http://mondo.devdaily.com/Content/1/1/). But once I changed the servlet mapping as shown above, it started working like a champ.

Tomcat, pathinfo, and servlets

标签:

原文地址:http://www.cnblogs.com/hephec/p/4586854.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!