spring-servlet.xml简单示例
spring-servlet.xml简单示例
某个项目中的spring-servlet.xml 记下来以后研究用
<!-- springMVC简单配置 -->
<?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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.directwebremoting.org/schema/spring-dwr
http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
"> <mvc:annotation-driven />
<aop:aspectj-autoproxy /> <!-- 自动扫描并注入 -->
<context:component-scan base-package="net.crm" ></context:component-scan> <!-- 文件上传 -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- 设置上传文件的最大尺寸为1MB -->
<property name="maxUploadSize">
<value>101048576</value>
</property>
</bean> <!-- SpringMVC在超出上传文件限制时,会抛出org.springframework.web.multipart.MaxUploadSizeExceededException -->
<!-- 该异常是SpringMVC在检查上传的文件信息时抛出来的,而且此时还没有进入到Controller方法中 -->
<bean id="exceptionResolver"
class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<!-- 遇到MaxUploadSizeExceededException异常时,自动跳转到/WEB-INF/page/500.jsp页面 -->
<prop
key="org.springframework.web.multipart.MaxUploadSizeExceededException">500</prop>
</props>
</property>
</bean> <!-- 对静态资源的访问 -->
<mvc:resources location="/" mapping="/**/*.html"/>
<mvc:resources location="/font/" mapping="/font/**"/>
<mvc:resources location="/images/" mapping="/images/**"/>
<mvc:resources location="/javascripts/" mapping="/javascripts/**"/>
<mvc:resources location="/stylesheets/" mapping="/stylesheets/**"/> <!-- 个人登录过滤器 -->
<mvc:interceptors>
<!-- 拦截器 -->
<mvc:interceptor>
<mvc:mapping path="/user/**"/>
<mvc:mapping path="/role/**"/>
<mvc:mapping path="/systerm/**"/>
<mvc:mapping path="/manage/**"/>
<mvc:mapping path="/customer/**"/>
<mvc:mapping path="/resume/**"/>
<bean class="net.crm.base.interceptor.UserLoginInterceptor"></bean>
</mvc:interceptor>
<mvc:interceptor>
<mvc:mapping path="/user/**"/>
<mvc:mapping path="/role/**"/>
<mvc:mapping path="/systerm/**"/>
<mvc:mapping path="/manage/**"/>
<mvc:mapping path="/customer/**"/>
<mvc:mapping path="/resume/**"/>
<bean class="net.crm.base.interceptor.RoleInterceptor"></bean>
</mvc:interceptor> </mvc:interceptors> <bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> -->
<property name="prefix" value="/WEB-INF/page/" />
<property name="suffix" value=".jsp" />
<property name="order" value="1" />
</bean> <!-- 从这行往下是要添加的 -->
<context:annotation-config />
<dwr:configuration />
<dwr:annotation-config />
<dwr:url-mapping />
<dwr:controller id="dwrController" debug="true">
<dwr:config-param name="allowScriptTagRemoting"
value="true" />
<dwr:config-param name="crossDomainSessionSecurity"
value="false" />
</dwr:controller>
<beans:bean
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<beans:property name="order" value="1" />
</beans:bean>
<beans:bean
class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping">
<beans:property name="order" value="2" />
</beans:bean>
<!--添加结束--> </beans>
第二个
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd"> <!-- 拦截器 -->
<mvc:interceptors>
<mvc:interceptor>
<!-- 拦截类型 -->
<mvc:mapping path="/**" />
<!-- 排除拦截的内容 -->
<mvc:exclude-mapping path="/login" />
<mvc:exclude-mapping path="/register" />
<mvc:exclude-mapping path="/verifycode" />
<mvc:exclude-mapping path="/js/**" />
<mvc:exclude-mapping path="/css/**" />
<mvc:exclude-mapping path="/layer/**" />
<mvc:exclude-mapping path="/style/**" />
<bean
class="com.jieyou.login_register.AuthorityInterceptor.AuthorityInterceptor" />
</mvc:interceptor>
</mvc:interceptors> <!-- 默认首页 -->
<mvc:view-controller path="/" view-name="redirect:/login" /> <!-- 用于支持Servlet、JSP视图解析 -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 表示JSP模板页面需要使用JSTL标签库,classpath中必须包含jstl的相关jar包 -->
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<!-- 查找视图页面的前缀和后缀 -->
<property name="prefix" value="/WEB-INF/view/" />
<property name="suffix" value=".jsp" />
</bean> <!-- 对静态资源文件的访问 -->
<mvc:resources location="/css/" mapping="/css/**"
cache-period="31556926" />
<mvc:resources location="/js/" mapping="/js/**"
cache-period="31556926" />
<mvc:resources location="/style/" mapping="/style/**"
cache-period="31556926" /> <mvc:default-servlet-handler /> </beans>
spring-servlet.xml简单示例的更多相关文章
- JAVA入门[20]-Spring Data JPA简单示例
Spring 对 JPA 的支持已经非常强大,开发者只需关心核心业务逻辑的实现代码,无需过多关注 EntityManager 的创建.事务处理等 JPA 相关的处理.Spring Data JPA更是 ...
- spring boot thymeleaf简单示例
说实话,用起来很难受,但是人家官方推荐,咱得学 如果打成jar,这个就合适了,jsp需要容器支持 引入依赖 <dependency> <groupId>org.springfr ...
- LINQ for XML简单示例
LINQ,语言集成查询(Language Integrated Query)是一组用于c#和Visual Basic语言的扩展.它允许开发人员以与查询数据库相同的方式操作内存数据.从技术角度而言,LI ...
- Spring AOP的简单示例
配置文件 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://w ...
- Spring JdbcTemplate + transactionTemplate 简单示例 (零配置)
jdbcTemplate简介 Spring对数据库的操作在jdbc上面做了深层次的封装,使用spring的注入功能,可以把DataSource注册到JdbcTemplate之中. JdbcTempla ...
- JSP+Servlet+mysql简单示例【图文教程】
下载MYSQL:http://dev.mysql.com/downloads/ 下载安装版的 然后安装(安装步骤就不详细说了) 安装好之后,点击托盘图标,打开管理工具 创建一个数据库 数据库的名字 ...
- C# linq to xml 简单示例
data.xml <?xml version="1.0" encoding="utf-8" ?> <Data> <Products ...
- MogliFS与spring mvc结合简单示例
一.MogliFS 与Spring结合配置请参照上文 二.上传页面 <%@ page language="java" contentType="text/html; ...
- Spring+CXF的WebServices简单示例
本文就最简单的WebServices示例来演示Spring和CXF的整合. 使用Maven创建webapp项目,pom如下 <properties> <cxf.version> ...
随机推荐
- Object[]arr代码输出奇怪字符的解释
代码:class lizi { public static void main(String[] args){ //TODO Auto-generated method stub Object[ ...
- Linux内核中大小端判定宏
#include <stdio.h> ];unsigned long mylong;} endian_test = { {'l','?','?','b'} }; #define ENDIA ...
- LUA脚本调用C场景,使用C API访问脚本构造的表
LUA调用C lua解析中集成了一些系统服务, 故脚本中可以访问系统资源, 例如, lua脚本可以调用文件系统接口, 可以调用数学库, 但是总存在一些lua脚本中访问不到的系统服务或者扩展功能, 如果 ...
- SQL scripts
Add a column with default current date timeALTER TABLE [TableName]ADD CreatedOn DATETIME NOT NULL DE ...
- 【转】数据库系统异常排查之DMV
数据库系统异常是DBA经常要面临的情景,一名有一定从业经验的DBA,都会有自己一套故障排查的方法和步骤,此文为为大家介绍一下通过系统 性能视图(SQLServer05以上版本)来排查系统异常的基本方法 ...
- Python 字符串方法详解
Python 字符串方法详解 本文最初发表于赖勇浩(恋花蝶)的博客(http://blog.csdn.net/lanphaday),如蒙转载,敬请保留全文完整,切勿去除本声明和作者信息. ...
- 如何用openvr api打开vive前置摄像头
随着越来越多的开发者开始他们的VR开发工作,他们看到了这项技术的巨大潜力,像是Valve这样的公司正在想办法保证他们的软件开发包(SDK)能够提供尽量多的功能.今天这家公司发布了其针对SteamVR的 ...
- Azure web role, work role 以及其他role
Azure web role, work role 以及其他role 如果没有创建过web role 和work role的话可以参考如下文章来创建一下web role 和work role. htt ...
- HtmlHelper的扩展
HtmlHelper的扩展: 注意点:扩展方法必须是静态方法,所在的类必须是静态类,所在的命名空间改成System.Web.MVC则能省略页面中必须添加命名空间的约束. //主要就是输出分页的超级链接 ...
- Linux内核链表深度分析【转】
本文转载自:http://blog.csdn.net/coding__madman/article/details/51325646 链表简介: 链表是一种常用的数据结构,它通过指针将一系列数据节点连 ...