spring 4.2.6 mvc 静态资源访问问题

问题描述

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

spring 4.2.6 mvc 静态资源访问问题的相关文章

js引用-spring mvc 静态资源不能引用 已经配置了不拦截静态资源!!!

问题描述 spring mvc 静态资源不能引用 已经配置了不拦截静态资源!!! 页面中引用 web.xml中配置 springorg.springframework.web.servlet.DispatcherServlet <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/classes/spring-servlet.xml</para

配置-关于spring mvc静态资源 加载的问题

问题描述 关于spring mvc静态资源 加载的问题 浏览器报了这样的错误 然后小弟的项目里面是这样配置滴: 解决方案 第一行错误就显示jquery没找到,$肯定也就不好使了.可以在src里加上"${pageContext.request.contextPath}/"配完整路径 解决方案二: 不能用 /js 开头,应该这样写:/web工程名/js .... 这是个非常基础的问题,建议看下 html 相关知识 解决方案三: 1可能是你用的SpringMVC框架,拦截了静态资源.你检查下

spring-使用SpringMVC 静态资源访问 报错ConversionFailedException

问题描述 使用SpringMVC 静态资源访问 报错ConversionFailedException 使用的spring 版本是 4.20 在springmvc配置 报错很奇怪.. 解决方案 该错误是因为: 1.内嵌jetty在运行时会锁定静态资源:因此在运行过程中不能删除静态资源: 2.问题的根源是启动了多个jetty实例,但是实际没有报端口冲突,可以检查任务管理器看是否有多个java/javaw进程在运行,如果是杀掉进程然后重试. 解决方案二: 配置这个没? <mvc:resources

Spring Boot 设置静态资源访问

问题描述 当使用spring Boot来架设服务系统时,有时候也需要用到前端页面,当然就不可或缺地需要访问其他一些静态资源,比如图片.css.js等文件.那么如何设置Spring Boot网站可以访问得到这些静态资源,以及静态资源如何布局? 解决方案 这里引用stackoverflow网站的问题截图:[http://stackoverflow.com/questions/27381781/java-spring-boot-how-to-map-my-my-app-root-to-index-ht

REST风格的项目部署在tomcat上,静态资源如何访问

问题描述 服务器:tomcat6.0.29我的项目想用spring mvc框架,URL采用REST风格,但是这样一来,服务器上的静态资源访问不到了,麻烦高手给看一下.web.xml文件如下 <?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/j2ee"xmlns:xsi=&

【spring boot】7.静态资源和拦截器处理 以及继承WebMvcConfigurerAdapter类进行更多自定义配置

   开头是鸡蛋,后面全靠编!!! ========================================================  1.默认静态资源映射路径以及优先顺序   Spring Boot 默认为我们提供了静态资源处理,使用 WebMvcAutoConfiguration 中的配置各种属性. 建议大家使用Spring Boot的默认配置方式,提供的静态资源映射如下: classpath:/META-INF/resources classpath:/resources

静态资源-mvc:resources标签不起作用

问题描述 mvc:resources标签不起作用 只有根目录http://localhost:8080/agent__portal/这个根路径能访问的了,其他ctrl和静态资源都访问不了_ 解决方案 应该跟mvc:resources没关系: 先把ctrl搞得能访问再说,最后再看mvc:resources:把debug日志打开,看启动的时候你的ctrl创建成功没,路径是啥. 再有,排除跟路径不对的问题. 解决方案二: 错了,验证发现只有静态资源访问不了 mvc:resources标签怎么修改,删除

spring mvc 访问静态资源疑问

问题描述 前台页面需要访问静态页面,在没有配置<mvc:resourcesmapping="/css/**"location="/css/"/><mvc:resourcesmapping="/js/**"location="/js/"/>时,进行debug,程序启动后,前台还是能够访问的,虽然样式加载不出来,但是确实是可以访问的.但是当我为了要访问静态资源,所以加上上面的配置后,程序启动后,前台访问,反

Spring MVC中如何防止静态资源被Interceptor过滤

问题描述 我的配置是web.xml<servlet> <servlet-name>appServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name>