Java EE 6中的欢迎页面 [英] Welcome pages in java ee 6

查看:76
本文介绍了Java EE 6中的欢迎页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为对问题的后续措施,可以指定没有web.xml的欢迎页面吗?如果可能的话,怎么办?如果不可能,是否仅不使用欢迎页面?如果不使用,优点和缺点是什么?

As a follow up to this question, can one specify the welcome pages without web.xml? If possible, how? If not possible, are welcome pages simply not used? If not used, what are the advantages and disadvantages?

推荐答案

您可以指定欢迎页面,而无需在web.xml中进行声明.您使用一些html文件,然后转到所需的开始页面.请参见示例,

You can specify the welcome page without declare in web.xml. You use some html file and forward to your desire start page.see sample,

index.jsp

index.jsp

  <html>
  <body>
  <jsp:forward page="/pages/welcome.jsf" />
  </body>
  </html>

index.jsp页面前进到welcome.jsf页面,而无需在您的web.xml中声明到welcome-file-list标记.

The index.jsp page forward to welcome.jsf page without declare to welcome-file-list tag in your web.xml.

使用欢迎文件列表的优势

当URL请求是目录名时,Application Server将提供welcome-file-list元素中指定的第一个文件.

When the URL request is a directory name, Application Server serves the first file specified in welcome-file-list element.

不使用欢迎文件列表的缺点

如果未找到该欢迎文件列表,则服务器将尝试web.xml中的下一个文件,这花费了更多时间,并且可能会发现404错误.

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.

这篇关于Java EE 6中的欢迎页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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