0

我有一个网络应用程序。我正在使用 JSF2 框架。在谷歌应用引擎服务器上运行这个项目时,我的问题开始了。

<welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>

这部分 web.xml 文件没有给出正确的输出。当我输入 localhost:8080 时,找不到 index.html 页面。怎么了?请帮忙。完整的 web.xml 文件是:

 <?xml version="1.0" encoding="UTF-8"?>
<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_2_5.xsd"
         id="WebApp_ID" version="2.5">
    <display-name>
        Wildstar Technologies, LLC. Google AppEngine JSF 2.0 Template
    </display-name>
    <description>
        Template JSF 2.0 application configured to run on the Google
        AppEngine for Java.
    </description>

    <context-param>
        <param-name>primefaces.THEME</param-name>
        <param-value>cupertino</param-value>
    </context-param>
    <context-param>
        <param-name>com.ocpsoft.pretty.DEVELOPMENT</param-name>
        <param-value>/WEB-INF/pretty-config.xml</param-value>
    </context-param>
    <servlet>
        <display-name>Remote API Servlet</display-name>
        <servlet-name>RemoteApiServlet</servlet-name>
        <servlet-class>com.google.apphosting.utils.remoteapi.RemoteApiServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>RemoteApiServlet</servlet-name>
        <url-pattern>/remote_api</url-pattern>
    </servlet-mapping>
    <servlet>
        <servlet-name>ShowImage</servlet-name>
        <servlet-class>mucayufa.web.jsf2.ferizliAdmin.beans.ShowImage</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>ShowImage</servlet-name>
        <url-pattern>/show</url-pattern>
    </servlet-mapping>
    <servlet>
        <servlet-name>Upload</servlet-name>
        <servlet-class>mucayufa.web.jsf2.ferizliAdmin.beans.UploadDocument</servlet-class>
    </servlet>

    <servlet>
        <servlet-name>Serve</servlet-name>
        <servlet-class>mucayufa.web.jsf2.ferizliAdmin.beans.Serve</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>Upload</servlet-name>
        <url-pattern>/upload</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>Serve</servlet-name>
        <url-pattern>/serve</url-pattern>
    </servlet-mapping>
    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern><!--*/-->
    </filter-mapping>
    <filter>
        <filter-name>PrimeFaces FileUpload Filter</filter-name>
        <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>PrimeFaces FileUpload Filter</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>

    <!-- Processes application requests -->
    <servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/applicationContext.xml</param-value>
        </init-param>

    </servlet>

    <servlet-mapping>
        <servlet-name>appServlet</servlet-name>
        <url-pattern>/*</url-pattern><!--*/-->
    </servlet-mapping>

    <filter>
        <filter-name>encodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>encodingFilter</filter-name>
        <url-pattern>/*</url-pattern><!--*/-->
    </filter-mapping>

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

    <!-- ***** Designate server-side state saving. *****  -->
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</param-value>
    </context-param>

    <context-param>
        <param-name>com.sun.faces.expressionFactory</param-name>
        <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
    </context-param>
    <!-- Disable use of threading for single-threaded environments such as
 the Google AppEngine. -->
    <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>
    <!-- ***** Load the JavaServer Faces Servlet ***** -->
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <!-- ***** Load the JavaServer Faces Servlet ***** -->

    <!-- Map these files with JSF -->
    <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>
    <!-- ***** Specify session timeout of thirty (30) minutes. ***** -->
    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>
 <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
</web-app>
4

2 回答 2

1

不确定这是否是您的问题,但我的经验是有时在 devmode 下,找不到静态资源。

虽然这里说“默认情况下,WAR 中的所有文件都被视为静态文件和资源文件” https://developers.google.com/appengine/docs/java/config/appconfig#Static_Files_and_Resource_Files,但我肯定遇到过案例静态资源在开发模式下无法解析,即使它们应该并且在生产中执行。

我的意思是,如果在appengine-web.xml 中没有<include path="**.html" /> 的映射,例如html 文件不会被视为静态资源。

我会在 appengine-web.xml 中尝试一个显式的 <include> 映射,并确保没有 <exclude> 通配符路径可能解析为该文件,因为开发服务器似乎处理得不好。

于 2012-06-23T12:27:45.820 回答
-2

我有一个条目

<url-pattern>/</url-pattern>

在 web.xml 中。评论说,它的工作...

于 2018-05-09T15:49:45.333 回答