如何在spring mvc中设置welcome文件?

时间:2016-05-22 13:20:20

标签: spring spring-mvc servlets

我需要将index.html文件添加为欢迎页面,但问题是我不想为appServlet添加一些前缀。这是我的web.xml文件:

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

<servlet>
    <servlet-name>appServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
        <servlet-name>appServlet</servlet-name>
        <url-pattern>/*</url-pattern>
</servlet-mapping>

我将index.html文件放在我项目的webb文件夹中。我相信问题是appServlet映射到/ *这就是为什么当我尝试访问myDomain / index.html或myDomain /我得到404错误时。

0 个答案:

没有答案
相关问题