Because the Web. XML is configured with the
<servlet-mapping><servlet-name>appservlet</servlet-name><url-pattern>/</url-pattern ></servlet-mapping>
Causes all connections to be dispatcherservlet, so static resources such as css,js,images are filtered to make the page impossible to render successfully.
However, in the main configuration file, we can add <mvc:resources location= "", so that the static resources will not go through the Dispatcherservlet, you can successfully render the page.
<!--requests to handle static resources--><mvc:resources location= "/web-inf/views/css/" mapping= "/css/**"/><mvc:resources location= "/web-inf/views/js/" mapping= "/js/**"/><mvc:resources location= "/images/" mapping= "/images/**"/ >
However, the SPRINGMVC also has a mechanism for interceptors (if you don't use interceptors, then there's no problem), but it also intercepts the request link to our static resources.
By the output I saw in the interceptor, I actually intercepted the request link to the static resource, so my page would have the following error:
Resource interpreted as Stylesheet but transferred with MIME type text/html:
I still didn't find any other reason, so I filtered the static resource link on the interceptor, and then didn't produce the above problem.
While the other pages do not produce the above problem, but the static resources to filter the link, should not have any impact.
<mvc:interceptors><mvc:interceptor><mvc:mapping path= "/**"/> <!--because I've blocked all the links, the links to the static resources have been blocked. --><mvc:exclude-mapping path= "/js/**"/><mvc:exclude-mapping path= "/css/**"/><MVC: Exclude-mapping path= "/images/**"/><bean class= "Com.databasegroup.interceptor.AuthInterceptor" ></ Bean></mvc:interceptor></mvc:interceptors>
SPRINGMVC Interceptor (interceptors) to the style (CSS), JavaScript (JS), picture (images) Link interception