【问题标题】:JSF tags not rendering after update page to use new namespace xmlns.jcp.org更新页面以使用新命名空间 xmlns.jcp.org 后,JSF 标记未呈现
【发布时间】:2014-12-26 21:11:26
【问题描述】:

我有一个在 tomcat 8 上运行的 maven webapp 项目。 如果我使用旧的命名空间http://java.sun.com/jsf/html 它工作正常,但是使用新的命名空间,JSF 标记在浏览器上查看后不会呈现。 这些是我的依赖项:

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.2.2</version>
    </dependency>

    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>2.2.2</version>
    </dependency>
</dependencies>

这是我的 faces-config.xml:

<faces-config version="2.2"
              xmlns="http://xmlns.jcp.org/xml/ns/javaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
</faces-config>

我做错了什么?

---更新--- 这是我的 web.xml:

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         id="WebApp_ID" version="3.0">
    <display-name>Archetype Created Web Application</display-name>
    <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>*.xhtml</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>index.xhtml</welcome-file>
    </welcome-file-list>
    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>
</web-app>

【问题讨论】:

  • 您是如何配置 FacesServlet 的?
  • 查看我更新的问题

标签: java maven jsf jsf-2


【解决方案1】:

尝试使用新命名空间的 3.1 版:

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
    xmlns:web="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    version="3.1">

【讨论】:

    【解决方案2】:

    代替

        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.2.2</version>
        </dependency>
    
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.2.2</version>
        </dependency>
    

    使用

    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.faces</artifactId>
        <version>2.2.2</version>
    </dependency>
    

    【讨论】:

      猜你喜欢
      • 2013-10-18
      • 2015-08-31
      • 1970-01-01
      • 2018-08-19
      • 2013-05-17
      • 2019-09-12
      • 1970-01-01
      • 2013-09-02
      • 2013-08-28
      相关资源
      最近更新 更多