如何使用子文件夹作为 web.xml 欢迎目录 [英] How to use a sub-folder as web.xml welcome directory
问题描述
我想为 Google App Engine 配置我的 web.xml,但我的配置不起作用.我想用 WebApp/index.html
更改默认的 index.html
.
I want to configure my web.xml for Google App Engine, but my configuration doesn't work. I want to change the default index.html
with WebApp/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>
推荐答案
欢迎文件"表示当 URL 请求文件夹时需要提供的物理文件.例如./
或 /WebApp/
或 WebApp/foo/
.它不代表主页文件".或者许多初学者似乎认为.让欢迎文件指向子文件夹是没有意义的.当请求另一个子文件夹时,它会失败.
The "welcome file" represents the physical file which needs to be served when a folder is requested by URL. E.g. /
or /WebApp/
or WebApp/foo/
. It does not represent the "homepage file" or so as many starters seem to think. It does not make sense to let the welcome file point to a subfolder. It would fail when another subfolder is been requested.
只需将 index.html
作为欢迎文件,将所需的主页文件放在 /WebApp/
文件夹中并创建另一个 index.html
根文件夹 /
中的文件,内容如下:
Just stick to index.html
as welcome file, put the desired homepage file in /WebApp/
folder and create another index.html
file in root folder /
with the following content:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dummy homepage</title>
<meta http-equiv="refresh" content="0; url=WebApp" />
</head>
</html>
这将重定向到 /WebApp/
(搜索机器人会将其视为 301),后者将提供所需的主页文件.
This will redirect to /WebApp/
(searchbots will treat it as 301) which in turn should serve the desired homepage file.
这篇关于如何使用子文件夹作为 web.xml 欢迎目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!