目录中的web.xml默认文件(对于码头还是tomcat)? [英] web.xml default file in directory (for jetty, or tomcat)?

查看:147
本文介绍了目录中的web.xml默认文件(对于码头还是tomcat)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为./welcome/的目录,而./welcome/有一个名为./index.jsp的文件.

我知道如何告诉码头或tomcat如何从./wecome/index.jsp开始.但是,我还有很多其他带有./index.jsp的目录,例如--- ./blogs/、./whatever/等.

无需使用servlet,就可以告诉Jetty或tomcat,嘿,每当您收到目录请求时,请查看是否存在./index.jsp并将其显示给用户. /p>

就像我访问./blogs/一样,我不想看到未找到404.我想查看./blogs/index.jsp的内容,但是我不希望我的用户重定向到./blogs/index.jsp -我希望他们的浏览器仍然只显示./blogs/

我知道apache具有这样的功能.任何帮助将不胜感激,谢谢.

解决方案

嘿,每当您收到目录请求时,请查看是否存在./index.jsp并将其显示给用户."

这正是welcome-file-list应该做的.

只需将以下内容添加到web.xml中.在这种情况下,首先容器将尝试index.html,如果不存在,则将尝试index.jsp.

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

我已经在Tomcat 5.5上对其进行了测试,并且可以正常工作.

不幸的是,很难找到web.xml的官方参考.因此,此处是Oracle的文档代替weblogic;我认为它是可以信任的...

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

I know how to tell jetty or tomcat 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...

这篇关于目录中的web.xml默认文件(对于码头还是tomcat)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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