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简单示例的更多相关文章

  1. JAVA入门[20]-Spring Data JPA简单示例

    Spring 对 JPA 的支持已经非常强大,开发者只需关心核心业务逻辑的实现代码,无需过多关注 EntityManager 的创建.事务处理等 JPA 相关的处理.Spring Data JPA更是 ...

  2. spring boot thymeleaf简单示例

    说实话,用起来很难受,但是人家官方推荐,咱得学 如果打成jar,这个就合适了,jsp需要容器支持 引入依赖 <dependency> <groupId>org.springfr ...

  3. LINQ for XML简单示例

    LINQ,语言集成查询(Language Integrated Query)是一组用于c#和Visual Basic语言的扩展.它允许开发人员以与查询数据库相同的方式操作内存数据.从技术角度而言,LI ...

  4. Spring AOP的简单示例

    配置文件 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://w ...

  5. Spring JdbcTemplate + transactionTemplate 简单示例 (零配置)

    jdbcTemplate简介 Spring对数据库的操作在jdbc上面做了深层次的封装,使用spring的注入功能,可以把DataSource注册到JdbcTemplate之中. JdbcTempla ...

  6. JSP+Servlet+mysql简单示例【图文教程】

    下载MYSQL:http://dev.mysql.com/downloads/ 下载安装版的 然后安装(安装步骤就不详细说了) 安装好之后,点击托盘图标,打开管理工具 创建一个数据库   数据库的名字 ...

  7. C# linq to xml 简单示例

    data.xml <?xml version="1.0" encoding="utf-8" ?> <Data> <Products ...

  8. MogliFS与spring mvc结合简单示例

    一.MogliFS 与Spring结合配置请参照上文 二.上传页面 <%@ page language="java" contentType="text/html; ...

  9. Spring+CXF的WebServices简单示例

    本文就最简单的WebServices示例来演示Spring和CXF的整合. 使用Maven创建webapp项目,pom如下 <properties> <cxf.version> ...

随机推荐

  1. 转贴: 更改Outlook2013数据文件的位置

    转自: 老田博客 近日体验了一下微软OFFICE 2013 说实话 除了与skydriver深度整合实现云同步文档外 其他的功能对我这样的『Light User』实在是大材小用 wps足够了 在使用过 ...

  2. java 虚拟机--新生代与老年代GC

    Heap: JVM只有一个为所有线程所共享的堆,所有的类实例和数组都是在堆中创建的. Method area: JVM只有一个为所有的线程所共享的方法区.它存储类结构,例如运行时常量池,成员和方法数据 ...

  3. oracle: tochar(sysdate,'D')函数

    学习oracle时碰到tochar(sysdate,'D')函数,但是发现并不是星期几,如今天是20150317,周二,但是得到的值为3 开始以为是系统日期什么的原因,试了试 select to_ch ...

  4. ELK笔记

    ELK笔记 ELKStack高级实战培训http://files.cnblogs.com/files/MYSQLZOUQI/ELKStack%E9%AB%98%E7%BA%A7%E5%AE%9E%E6 ...

  5. 服务器IP地址后修改SQL Server配置

    1. 修改TCP/IP 属性的IP 地址 修改该实例的协议.修改TCP/IP协议的属性,将IP地址更新为当前的最新IP 地址.然后重启该实例. 2.查看全部侦听再检查SQL Server 实例的TCP ...

  6. Linux:挂载外部U盘,移动数据

    背景: 我自己电脑连网采用拨号上网方式,为了把自己的虚拟机中的服务器ip域本机设置为一个局域网,而且ip固定下来,虚拟机网络连接采用了桥接方式.所以也导致了虚拟机内部没法连接外网.(不过可以通过在虚拟 ...

  7. JDBC连接mysql数据库,添加数据

    如下:其中添加/删除/修改只是sql字符串不同 //3.要执行的字符串 String sql="INSERT INTO t_student(NAME,age,email) VALUES('x ...

  8. JS按回车键实现登录的方法

    本文实例讲述了JS按回车键实现登录的方法,该功能有着非常广泛的实用价值.分享给大家供大家参考之用.具体方法如下: 方法一: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 < ...

  9. 郑轻校赛题目 问题 G: 多少个0

    问题 G: 多少个0 时间限制: 1 Sec  内存限制: 128 MB提交: 192  解决: 40 题目描述 一个n*n的方格,每个格子中间有一个数字是2或者5,现在从方格的左上角走到右下角,每次 ...

  10. JetBrains WebStorm 安装破解问题

    1.选择用户名验证码注册,进入地址:http://15.idea.lanyus.com/ 然后输入用户名,提交便会生成验证码,注册成功, 2.选择License server,输入以下地址: http ...