【问题标题】:Google App Engine - JSF - Facelets - Why not *.xhtml as a url-pattern?Google App Engine - JSF - Facelets - 为什么不将 *.xhtml 作为 url 模式?
【发布时间】:2012-05-26 22:36:45
【问题描述】:

我正在将现有应用程序从 Tomcat 迁移到 GAE。在本地测试时,xhtml 页面作为静态页面加载。所有处理都被绕过,包括我的过滤器。但是,如果我引用一个不存在的页面,我的安全过滤器会将请求转发到 login.xhtml 并且 JSF/facelet 呈现正常。

知道为什么要处理 xhtml 页面吗?

其他集成:eclipse Helios、gae 1.6.5、maven (eclipse/m2)、moharra 2.0.9、richfaces 4.2.0、spring 3.1.1

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

    <!-- https://community.jboss.org/wiki/HowToUseRichFaces40WithGoogleAppEngine -->
   <context-param>
      <param-name>com.sun.faces.enableThreading</param-name>
      <param-value>false</param-value>
   </context-param>
     <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Production</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</param-value>
    </context-param>


 <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
 </context-param>

<listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<listener>
  <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>


 <filter>
  <filter-name>SecurityFilter</filter-name>
  <filter-class>com.xyz.web.filter.SecurityFilter</filter-class>
 </filter>
 <filter-mapping>
  <filter-name>SecurityFilter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>

 <servlet>
  <servlet-name>Faces Servlet</servlet-name>
  <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
 </servlet>

 <servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>*.xhtml</url-pattern>
 </servlet-mapping>

    <servlet>
        <servlet-name>Resource Servlet</servlet-name>
        <servlet-class>org.richfaces.webapp.ResourceServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Resource Servlet</servlet-name>
        <url-pattern>/org.richfaces.resources/*</url-pattern>
    </servlet-mapping>

</web-app>

更新: 如果我添加以下映射并引用扩展名为 .jsf 的页面,它会起作用。直接引用 .xhtml ,仍然会加载源代码。为 .xhtml 引用 .jsf 扩展名是典型配置吗?如果是这样,您如何配置应用程序以使通过 .xhtml 访问时源不可用?

 <servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>*.jsf</url-pattern>
 </servlet-mapping>

【问题讨论】:

  • 寻找 mkyoung 精美教程.. 可能会在那里找到一些东西... google.com/…
  • 再次感谢。剩下的一个问题是为什么 .xhtml url-pattern 不能像 BalusC 在该线程中建议的那样在 GAE 上工作。我将再次修改问题并保持开放状态。
  • GAE 运行在 Jetty 服务器上做一些谷歌搜索,可能会找到一些信息,但之前请仔细检查......因为你可能会错过一些东西......
  • 会的。你已经两次成为我的私人谷歌助理了。我会从这里拿走。 :)

标签: google-app-engine jsf-2 facelets


【解决方案1】:

如果我正确理解您的需求,您应该添加

<static-files>
    <exclude path="/**.xhtml" />
</static-files>

在 appengine-web.xml 中

如果你跳过这个,你的网络浏览器会得到来自“静态文件服务器”的回复,而不是来自 JSF。

【讨论】:

    猜你喜欢
    • 2019-03-06
    • 1970-01-01
    • 2015-07-11
    • 1970-01-01
    • 2011-07-25
    • 2012-01-30
    • 1970-01-01
    • 2012-07-11
    • 1970-01-01
    相关资源
    最近更新 更多