【发布时间】:2012-11-06 17:46:13
【问题描述】:
我已经使用 Eclipse Indigo 和 Tomcat 7.0.32 创建了一个 JSF 2.0 应用程序,如 Eclipse Documentation 所示。
在这个应用程序中,我有两个页面:
- login.xhtml
- welcome.xhtml
从login.xhtml 我导航到welcome.xhtml。
我已将login.xhtml 声明为我的web.xml 中的欢迎页面。
<welcome-file-list>
<welcome-file>login.xhtml</welcome-file>
</welcome-file-list>
并且还将url-pattern 的Faces Servlet 定义为:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
现在我有两个问题:
- 当我访问 URL
http://localhost:8080/LibraryInformationSystem/时,我可以看到登录页面,但登录后,当我导航到welcome.xhtml 时,URL 更改为http://localhost:8080/LibraryInformationSystem/login.xhtml而不是http://localhost:8080/LibraryInformationSystem/welcome.xhtml;但如果我手动浏览http://localhost:8080/LibraryInformationSystem/welcome.xhtml,它也会显示相同的内容。我的问题是为什么 URL 没有改变?这是定义默认页面的正确方法吗?我从另外两个 SO 线程中找到了信息,第一个是 here,第二个是 here。 - 第二个问题是,当我从 Eclipse 运行应用程序并将应用程序启动到其内部浏览器时,我可以看到登录页面,但如果我关闭从 Eclipse 运行的服务器并从批处理运行 Tomcat位于 bin 文件夹中的文件 startup.bat 并将应用程序导出为 war 文件并将其部署到 webapps 文件夹中,有时我可以看到登录页面,有时我会看到来自 Firefox 或 Chrome 的 Tomcat 的 HTTP 错误 - 404 页面。如果我关闭 startup.bat 并从 webapps 文件夹中删除 myapplication.war 和 myapplication 文件夹,然后再次从 startup.bat 启动服务器并再次从 Eclipse 导出 war 我可以看到登录页面,在这种情况下没有 404 错误.为什么会这样?
任何指针都会对我很有帮助。
【问题讨论】:
-
+1,如果做这件事的人感觉足够强烈,他会回来红自己的投票并解释
标签: java eclipse jsf-2 tomcat7