[Spring MVC]设置welcome-file样式失效/无法载入css,js文件

1.绝对路径/相对路径

  web.xml里的welcome-file-list里设置默认访问页面为/html/index.html

  但是在访问时,页面CSS都没加载。

  正常输入网址却没问题。用/html/index.jsp也没问题。配置如下

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

  CSS文件在与html文件夹同级的app目录里。html文件里的CSS路径为:app/main.css。

2.静态资源拦截

  在pom.xml加入,路径根据所需修改

<resources>
        <resource>
                <directory>web</directory>
                <includes>
                    <include>**/*.css</include>
                    <include>**/*.less</include>
                    <include>**/*.js</include>
                </includes>
                <filtering>false</filtering>
            </resource>
<resources>