spring mvc页面显示图片失败

时间:2022-10-10 08:44:50

在配置文件中需要映射静态资源

<!-- 当在web.xml 中   DispatcherServlet使用 <url-pattern>/</url-pattern> 映射时,能映射静态资源 -->
<mvc:default-servlet-handler/>
<!-- 静态资源映射,配置了<mvc:annotation-driven /> 才会起作用-->
<mvc:resources mapping="/html/**" location="/WEB-INF/html/"/>
<mvc:resources mapping="/js/**" location="/WEB-INF/js/"/>
<mvc:resources mapping="/css/**" location="/WEB-INF/css/"/>
<mvc:resources mapping="/images/**" location="/WEB-INF/images/"/>
<mvc:resources mapping="/data/**" location="/WEB-INF/data/"/>
<mvc:resources mapping="/fonts/**" location="/WEB-INF/fonts/"/>
<mvc:resources mapping="/upload/**" location="/WEB-INF/upload/"/>