8

我想为 Google App Engine 配置我的 web.xml,但我的配置不起作用。我想index.htmlWebApp/index.html.

这是web.xml

<servlet>
    <servlet-name>App</servlet-name>
    <servlet-class>bg.app.AppServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>App</servlet-name>
    <url-pattern>/WebApp/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>WebApp/index.html</welcome-file>
</welcome-file-list>
4

1 回答 1

16

“欢迎文件”表示通过 URL 请求文件夹时需要提供的物理文件。例如//WebApp/WebApp/foo/。它并不代表“主页文件”或许多初学者似乎认为的那样。让欢迎文件指向子文件夹是没有意义的。当请求另一个子文件夹时它会失败。

只需坚持index.html作为欢迎文件,将所需的主页文件放在文件夹中,然后在根文件夹中/WebApp/创建另一个文件,内容如下:index.html/

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Dummy homepage</title>
    <meta http-equiv="refresh" content="0; url=WebApp" />
  </head>
</html>

这将重定向到/WebApp/(搜索机器人将其视为 301),这反过来应该提供所需的主页文件。

也可以看看:

于 2013-05-07T18:35:57.147 回答