0

私は webapp extensions.war を tomcat 7 にデプロイしています。この戦争の最上位には index.html があります。ユーザーが言うhttp://server:port/extensions/ と、index.html が表示されます。

extensions.war の下に、indexOne.html と indexTwo.html という 2 つの HTML ページをさらに作成したいと考えています。

これらがそれぞれ extensions.war/indexOne.html と extensions.war/indexTwo.html を指すようなhttp://http://server:port/extensions/appOne URLをユーザーが使用するにはどうすればよいですか。http://http://server:port/extensions/appTwo

4

1 に答える 1

0

web.xml 構成で直接行う方法はありません。ウェルカム ファイル リストは、トップ レベルのファイルのみをサポートします。extensions/appOneURLと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);
}
于 2013-04-13T07:33:01.397 に答える