Banana_pupu 2020-04-24 11:00 采纳率: 0%
浏览 855

已解决 : springMvc访问不到静态资源的问题 (访问不到图片,css等

这是我的项目结构:
图片说明



我在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下的静态资源目录才能访问到静态资源。

  • 写回答

2条回答 默认 最新

  • 释怀然已 2020-04-24 11:17
    关注

    我的可以,你看下配置变量路径,下面图片
    图片说明

    评论

报告相同问题?

悬赏问题

  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM