开发者

web.xml default file in directory (for jetty, or tomcat)?

I have a directory called ./welcome/ and ./welcome/ has a file called ./index.jsp.

I know how to tell jetty or tomca开发者_开发百科t how to start at ./wecome/index.jsp. But, I also have lots of other directories with an ./index.jsp like --- ./blogs/, ./whatever/, etc.

Without using servlets, is there a way to tell jetty or tomcat, "hey, whenever you get a request for a directory, see if there is an ./index.jsp -- and display it to the user."

Like if I access ./blogs/ I dont want to see a 404 not found. I want to see the contents of ./blogs/index.jsp, but I dont want my users to be redirected to ./blogs/index.jsp -- I want their browsers to still only display ./blogs/

I know apache has such as feature. Any help would be appreciated, thanks.


"hey, whenever you get a request for a directory, see if there is an ./index.jsp -- and display it to the user."

That's exactly what welcome-file-list is supposed to do.

Simply add the following to web.xml. In this case, first the container will try index.html and if it does not exist, then it will try index.jsp.

<welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

I've tested this on Tomcat 5.5, and it works correctly.

Unfortunately, it's really hard to find the official reference for web.xml. So here is the documentation for Oracle weblogic instead; I think it can be trusted...


refer above:

first the container will try index.html and if it does not exist, then it will try index.jsp.

my app alway use index.html, when there are both index.jsp, index.html, regardless of the config sequense.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜