【发布时间】:2013-04-26 09:25:08
【问题描述】:
我有一个 JSF2 应用程序 我可以访问我的应用程序@http://tvmteleshopping.com/faces/ui/manageProfile.xhtml
但是当我使用 http://tvmteleshopping.com/ui/manageProfile.xhtml (没有 /faces/ ) 这个请求是由 Apache 而不是 tomcat 提供的。仅呈现任何静态 HTML 内容。
我使用 Apache 提供静态 HTML 文件,使用 tomcat 提供 *.xhtml 文件
我的 Servlet 映射很好: web.xml
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
我的 cp_jkmount.conf 将 jsp 和 jsf 文件重定向到 tocat 服务器。
<IfModule mod_jk.c>
JkMount /*.jsp ajp13
JKMount /*.do ajp13
JKMount /servlet/* ajp13
JKMount /servlets/* ajp13
JKMount /*.xhtml ajp13
JKMount /ui/* ajp13
JKMount /ui/*.xhtml ajp13
JKMount /faces/* ajp13
JKMount /*.jsf ajp13
</IfModule>
我有两个cp_jkmount.conf,一个在/usr/local/apache/conf/userdata/std/1/myuser/mysite.com/cp_jkmount.conf
还有一个 /usr/local/apache/conf/userdata/std/2/myuser/mysite.com/cp_jkmount.conf
而且我的两个 cp_jkmount 都是一样的。 我不知道为什么我在两个不同的目录中有两个 cp_jkmount.conf。
P.S:我的应用程序对于根文件夹中的那些 .xhtml 文件运行良好 http://tvmteleshopping.com/index.xhtml
为此,我认为我的 cp_jkmout.conf 工作正常。但是对于 'ui' 文件夹后面的那些 .xhtml 文件,它不起作用。
【问题讨论】:
-
您的
FacesServlet映射到 URL 模式/faces/*。因此,FacesServlet 不会拦截其他模式 -
@Vrushank 我认为这很好......因为我的网站在本地运行良好。服务器上的 apache 配置存在一些问题。如果是您所说的情况,则不应以这种方式访问 tvmteleshopping.com/index.xhtml(没有 /faces/)。
-
Vrushank 是对的,您可能正在点击 index.xhtml,因为它可能已被映射为欢迎文件。如果您不需要 /faces 前缀,则删除并使用 *.xhtml。
-
@Ravi 我的应用程序适用于根文件夹中的所有 .xhtml 文件,根文件夹中的其他页面(如 tvmteleshopping.com/products.xhtml)也可以正常工作。
-
尝试删除“/faces/*”映射。我猜问题是 JSF 正在等待根据您的映射文件以 /faces/* 开头并以 .jsf、.xhtml、.faces 结尾的任何模式。我不确定。
标签: apache jsf tomcat jsf-2 primefaces