zoukankan      html  css  js  c++  java
  • [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>    
  • 相关阅读:
    h5基本单词
    啦啦
    新内容
    Apache.PHP和MySQL的配置
    static关键字
    访问控制
    PHP Session
    PHP cookie
    全局空间
    使用use操作符导入/使用别名
  • 原文地址:https://www.cnblogs.com/zlc364624/p/14615555.html
Copyright © 2011-2022 走看看