如何将子文件夹用作web.xml的欢迎目录 [英] How to use a sub-folder as web.xml welcome directory

查看:137
本文介绍了如何将子文件夹用作web.xml的欢迎目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为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),然后它将提供所需的主页文件。

另请参阅:




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:

这篇关于如何将子文件夹用作web.xml的欢迎目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆