首页 > 代码库 > Spring配置文件
Spring配置文件
applicationContext.xml
<mvc:resources mapping="" location="">
主要用来进行静态资源的访问
首先使用spring mvc需要配置其使用的servlet.在web.xml中:
Java代码
- <servlet>
- <servlet-name>springMVC</servlet-name>
- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>springMVC</servlet-name>
- <url-pattern>/</url-pattern>
- </servlet-mapping>
springMVclanjie了所有请求
<servlet-mapping>
<servlet-name>springMVC</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
会影响到静态资源访问。
- <?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: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/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
- <mvc:resources mapping="/javascript/**" location="/static_resources/javascript/"/>
- <mvc:resources mapping="/styles/**" location="/static_resources/css/"/>
- <mvc:resources mapping="/images/**" location="/static_resources/images/"/>
- <mvc:default-servlet-handler />
- <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
- <property name="prefix" value=http://www.mamicode.com/"/WEB-INF/views/"/>
- <property name="suffix" value=http://www.mamicode.com/".jsp"/>
- </bean>
- </beans>
Spring配置文件
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。