java的struts2项目实现网站首页只显示域名不显示index.do的做法

自己的网站快做完了,发现首页显示的时候总是跳转到http://www.xxxxxx.com/index.do

而我想让http://www.xxxxxx.com/ 这样的方式来访问,不想带有后边的index.do

首先想到的是在web.xml加上欢迎页:

<welcome-file-list>
        <welcome-file>/index.jsp</welcome-file>
</welcome-file-list>

在index.jsp中:

<%@ page contentType="text/html;charset=utf-8" %>
<html>
    <header>
        <jsp:forward page="index.do" />
    </header>
</html>

但是这个时候并没有达到效果,还需要在web.xml里的struts过滤器里加上:

    <filter-mapping>
        <filter-name>struts</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping>
    此时启动程序,http://www.xxxxxx.com/就默认访问index.do了

原文地址:https://www.cnblogs.com/airfey/p/3175755.html