Web applications Tomcat web应用程序和浏览器url

Web applications Tomcat web应用程序和浏览器url,web-applications,indexing,tomcat7,Web Applications,Indexing,Tomcat7,我在tomcat 7中部署了一个webapp extensions.war。war在顶层有index.html。当用户说http://server:port/extensions/它会显示index.html 我想在extensions.war下再创建两个html页面,即indexOne.html和indexTwo.html 用户如何使用url,例如http://http://server:port/extensions/appOne和http://http://server:port/exte

我在tomcat 7中部署了一个webapp extensions.war。war在顶层有index.html。当用户说
http://server:port/extensions/
它会显示index.html

我想在extensions.war下再创建两个html页面,即indexOne.html和indexTwo.html


用户如何使用url,例如
http://http://server:port/extensions/appOne
http://http://server:port/extensions/appTwo
这样它们分别指向extensions.war/indexOne.html和extensions.war/indexTwo.html。

通过web.xml配置没有直接的方法。欢迎文件列表仅支持顶级文件。 请注意,URL
extensions/appOne
extensions/appTwo
不是顶级文件

您可以创建自己的过滤器,为自己的索引html文件提供服务:

if (isRequestTo(request,"appOne")) {
response.sendRedirect("/indexOne.html");
} 
if (isRequestTo(request,"appTwo")) {
response.sendRedirect("/indexTwo.html");
} 


public static boolean isRequestTo(HttpServletRequest request, String urlPart) {
    return request.getRequestURI().startsWith(urlPart);
}

如果我的答案回答了您的问题,您可以接受并推广我的答案:)