这是我的项目结构:
我在index.jsp中访问logo,png,url是这样写的:
springMvc的配置文件里已经写了resources配置:
运行index.jsp后
Idea显示如下:
10:43:27.170 [http-nio-8080-exec-3] DEBUG o.s.web.servlet.DispatcherServlet - DispatcherServlet with name 'dispatcher' processing GET request for [/movie/images/logo.png]
10:43:27.171 [http-nio-8080-exec-3] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Looking up handler method for path /images/logo.png
10:43:27.171 [http-nio-8080-exec-3] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Did not find handler method for [/images/logo.png]
10:43:27.171 [http-nio-8080-exec-3] DEBUG o.s.w.s.h.SimpleUrlHandlerMapping - Matching patterns for request [/images/logo.png] are [/images/**]
10:43:27.171 [http-nio-8080-exec-3] DEBUG o.s.w.s.h.SimpleUrlHandlerMapping - URI Template variables for request [/images/logo.png] are {}
10:43:27.171 [http-nio-8080-exec-3] DEBUG o.s.w.s.h.SimpleUrlHandlerMapping - Mapping [/images/logo.png] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/images/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@1c472712]]] and 1 interceptor
10:43:27.171 [http-nio-8080-exec-3] DEBUG o.s.web.servlet.DispatcherServlet - Last-Modified value for [/movie/images/logo.png] is: -1
10:43:27.172 [http-nio-8080-exec-3] DEBUG o.s.web.servlet.DispatcherServlet - Null ModelAndView returned to DispatcherServlet with name 'dispatcher': assuming HandlerAdapter completed request handling
10:43:27.172 [http-nio-8080-exec-3] DEBUG o.s.web.servlet.DispatcherServlet - Successfully completed request
不知道到底有什么问题,求大佬指点,感激不尽
解决方法:
不是配置问题。Idea从Target访问静态资源。Idea需要rebuild后才会更新target下的静态资源目录,build只更新classes。所以需要build->rebuild ,更新Target下的静态资源目录才能访问到静态资源。