[英]Welcome pages in java ee 6
You can specify the welcome page without declare in web.xml. 您可以在web.xml中指定欢迎页面而无需声明。 You use some html file and forward to your desire start page.see sample,
您使用一些html文件,然后转到所需的开始页面。请参见示例,
index.jsp index.jsp
<html>
<body>
<jsp:forward page="/pages/welcome.jsf" />
</body>
</html>
The index.jsp page forward to welcome.jsf page without declare to welcome-file-list tag in your web.xml. index.jsp页前进到welcome.jsf页,而无需在web.xml中声明到welcome-file-list标记。
Advantages of using welcome-file-list 使用欢迎文件列表的优点
When the URL request is a directory name, Application Server serves the first file specified in welcome-file-list element. 当URL请求是目录名时,Application Server将提供welcome-file-list元素中指定的第一个文件。
Disadvantages of without using welcome-file-list 不使用欢迎文件列表的缺点
If that welcome-file-list is not found, the server then tries the next file in the web.xml.Its taken more time and 404 error may be found. 如果找不到该欢迎文件列表,则服务器将尝试使用web.xml中的下一个文件,这花费了更多时间,并且可能会发现404错误。
The welcome files mechanism allows you to specify a list of files that the web container will use for appending to a request for a URL (called a valid partial request) that is not mapped to a web component.(from link ) 欢迎文件机制使您可以指定Web容器将用于追加到未映射到Web组件的URL请求(称为有效部分请求)的文件列表。(来自link )
Why don't you use a web.xml file ? 为什么不使用web.xml文件?
If you really don't want to use a web.xml file, then you could use a Filter to forward a request to your welcome page. 如果您确实不想使用web.xml文件,则可以使用过滤器将请求转发到欢迎页面。
Update: The web container should have a welcome file list of its own. 更新: Web容器应具有自己的欢迎文件列表。 For example Tomcat has a web.xml file in its conf folder.
例如,Tomcat在其conf文件夹中有一个web.xml文件。 It has
它有
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.