in  Insert the picture description here

springmvc reports error, cannot find static resource_mvc:resources reports error_Bai Xiaosen’s blog

class=”markdown_views prism-atom-one-dark”> 1. Question Static resources such as .png, .css, and .js cannot be found, resulting in no effect in many places on the webpage, as shown in the figure below 2. Solve Through searching, it is found that the problem lies in springmvc, and the blocking is set in the web.xml file as follows Although .png, .css, .js, etc. are intercepted, since springmvc has no corresponding processing for these requests, no static resources can be found, so we need to set something to help us deal with it These static resource requests Method 1: Use the default Servlet processing of the default web application server, configure it in the springmvc.xml configuration file mvc:default-servlet-handler /> Method 2: Use the Spring MVC framework to handle static resources by itself, and add some useful value-added functions allows static resources to be placed anywhere, such as under the WEB-INF directory, under the class path, etc., and you can even put static files such as JavaScript into the JAR package. Provide optimization for static resources according to the current famous Page Speed, YSlow and other browser optimization principles. mvc:resources location=”/,classpath:/META-INF/publicResources/” mapping= “/resources/**”/> Description: The location element represents all the files under the static package…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索