问题描述
- spring 4.2.6 mvc 静态资源访问问题
-
![新进公司, 尝试自己重新拾起搭一个springmvc框架,可是一个静态资源访问问
题拦住了我两天,求大神帮忙:图片说明](http://img.ask.csdn.net/upload/201605/20/1463737807_800158.png)
这是使用jar包web.xml 配置:
springmvc
<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:config/application*.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>springmvc</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:config/spring-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>springmvc</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list>
spring-mvc.xml配置:
<context:annotation-config /> <mvc:annotation-driven /> <mvc:resources mapping="/views/ui/**" location="/WEB-INF/views/ui/" /> <mvc:resources mapping="/views/new_ui/**" location="/WEB-INF/views/new_ui/" /> <context:component-scan base-package="com.aj.store" /> <!-- 完成请求和注解POJO的映射 --> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" /> <!-- 对模型视图添加前后缀 --> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/views/" p:suffix=".html" />
在网上搜了很多解决办法, 什么tomcat default 配置
等都试过。。
解决方案
spring mvc中对静态资源访问
Spring : 使用
spring mvc 配置对静态资源的访问
解决方案二:
http://bbs.csdn.net/topics/390594891
时间: 2024-08-30 02:19:22