0

Glassfish5:不调用 JSF FacesServlet。

例子.ear

    example_ejb.jar
    example_web.war

    META-INF/application.xml

META-INF/application.xml

<application 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/application_8.xsd"
             version="8">
    
    <module>
        <ejb>example_ejb.jar</ejb>
    </module>
    
    <module>
        <web>
            <web-uri>example_web.war</web-uri>
            <context-root>example_web</context-root>
        </web>
    </module>


    <library-directory>lib</library-directory>
</application>

example_web.war

WEB-INF/web.xml
home.xhtml

WEB-INF/web.xml

<web-app 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-app_4_0.xsd" 
         version="4.0">

    <servlet>
        <display-name>Faces Servlet</display-name>
        <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>
    
</web-app>

将 example.ear 部署到 Glassfish5,成功。但

http://localhost:8080/example_web/home.xhtml

HTTP 状态 404 - 未找到

在 FacesServlet.java 中设置断点,在调试模式下不调用 service() 方法。

4

0 回答 0