In order to introduce the CSS into the JSP, today is really stepping on a lot of pits, and finally found a solution on the StackOverflow, not much to say the code.
Add the following code to Web. XML:
< servlet-mapping > < Servlet-name >default</servlet-name> <Url-pattern >*.css</url-pattern> </ Servlet-mapping>
The Spring-servlet.xml configuration is as follows:
<?XML version= "1.0" encoding= "UTF-8"?><Beansxmlns= "Http://www.springframework.org/schema/beans"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xmlns:p= "http://www.springframework.org/schema/p"Xmlns:context= "Http://www.springframework.org/schema/context"Xmlns:mvc= "Http://www.springframework.org/schema/mvc"xsi:schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/ Spring-beans-3.0.xsd Http://www.springframework.org/schema/context Http://www.springframework.org/schema/cont Ext/spring-context-3.0.xsd Http://www.springframework.org/schema/mvc HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/MV C/spring-mvc.xsd "> <Mvc:annotation-driven/> <Mvc:default-servlet-handler/> <mvc:resourcesMapping= "/resources/**" Location= "/resources/css/"Cache-period= "31556926"/> <!--Scan Web packages, apply spring annotations - <Context:component-scanBase-package= "Main.com.winjay.blog.web"/> <!--Configure the View resolver to parse Modelandview and strings into specific pages - <Beanclass= "Org.springframework.web.servlet.view.InternalResourceViewResolver"P:viewclass= "Org.springframework.web.servlet.view.JstlView"P:prefix= "/web-inf/"P:suffix= ". jsp" /> </Beans>
Still not finished here, I began to put CSS containing floder in the Web-inf directory, found that still can not introduce CSS, and then I put that floder in the Webroot directory successfully introduced!
Spring MVC: Introducing CSS into the JSP