springmvc配置静态文件不起作用:
SpringMCV:
<mvc:resources mapping="/css/**" location="/resources/css/" />
页面:
<head>
<title>Title</title>
<link rel="stylesheet" href="resources/css/yapyan.css" />
浏览器控制台报如下错误:
Resource interpreted as Stylesheet but transferred with MIME type text/html:
"http://localhost:8080/resources/css/yapyan.css".
错误原因为:
Resource interpreted as Stylesheet but transferred with MIME type text/html
这是因为你请求 yapyan.css 文件时服务器的 Content-Type 内容为 text/html ,正确的应该是 text/css
试一下访问 js 文件,看看他的 Content-Type 是不是 application/javascript
你路径配置是
<mvc:resources mapping="/css/**" location="/resources/css/" />
那么请求 url 地址应该是
<link rel="stylesheet" type="text/css" href="/css/yapyan.css" />