springmvc对静态资源的访问
2016-04-17 23:36
465 查看
spring mvc 配置对静态资源的访问
在spring mvc的配置文件中做如下配置:1、
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> <context:component-scan base-package="com.vrvwh.wh01.controller"> </context:component-scan> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value=""></property> <property name="suffix" value=".jsp"></property> </bean> [code] <!-- 默认的注解映射的支持 --><mvc:annotation-driven />[/code]
<!--[code]对静态资源文件的访问-->
<mvc:default-servlet-handler />[/code]
</beans>
1、
<mvc:default-servlet-handler />
<!-- 这样根目录下面的resource的文件(.css,.js等)就不会被spring的DispatchServlet进行过滤 -->
2. <mvc:resources location="/resources/" mapping="/resources/**"/>
相关文章推荐
- 20145211 《Java程序设计》实验报告二:Java面向对象程序设计
- 20145316《Java程序设计》实验二报告
- 20145316《Java程序设计》第七周学习总结
- 20145303 实验二 Java面向对象程序设计
- Could not find action or result
- 《Java程序设计》第7周学习总结
- java设计模式--原始模型模式
- 20145101 《Java程序设计》第7周学习总结
- Java中创建线程的两种方式
- Java学习笔记一:基本语法:类和对象的介绍、数组、引用类型
- 20144303 《Java程序设计》第二次实验实验报告
- 《Java程序设计》第7周学习总结
- java基础(4)--Java中ArrayList和LinkedList区别
- java中length,length(),size()区别
- 使用WebMagic爬虫框架及javaEE SSH框架将数据保存到数据库(一)
- Spring中配置数据源的4种形式
- java基础之泛型
- Eclipse(Luna)查看class源代码文件
- java设计模式-单列模式
- 20145329 《Java程序设计》第七周学习总结