如何将子文件夹用作web.xml的欢迎目录 [英] How to use a sub-folder as web.xml welcome directory
问题描述
我想为Google App Engine配置我的web.xml,但我的配置不起作用。我想用 WebApp / index.html
更改默认的 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>
welcome file代表需要的物理文件通过URL请求文件夹时提供服务。例如。 /
或 / WebApp /
或 WebApp / foo /
。它并不代表许多首发者似乎认为的主页文件。让欢迎文件指向子文件夹是没有意义的。当另一个子文件夹被请求时,它会失败。
只要将 index.html
作为欢迎文件,在 / WebApp /
文件夹中创建所需的主页文件,并在根文件夹中创建另一个
包含以下内容: index.html
/
$ b
<!DOCTYPE html>
< html lang =en>
< head>
< title>虚拟主页< / title>
< meta http-equiv =refreshcontent =0; url = WebApp/>
< / head>
< / html>
这将重定向到 / WebApp /
(搜索机器人会将它视为301),然后它将提供所需的主页文件。
另请参阅:
- 如何配置欢迎文件列表在web.xml中
- 通过< welcome-file>设置默认主页在JSF项目中
- 使用doGet将根路径中的默认主页更改为servlet
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
.
Here is the 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>
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.
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>
This will redirect to /WebApp/
(searchbots will treat it as 301) which in turn should serve the desired homepage file.
See also:
- How to configure welcome file list in web.xml
- Set default home page via <welcome-file> in JSF project
- Change default homepage in root path to servlet with doGet
这篇关于如何将子文件夹用作web.xml的欢迎目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!