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. 浅谈Entity Framework 增删改查和事务操作

    1.增加对象 DbEntity db = new DbEntity(); //创建对象实体,注意,这里需要对所有属性进行赋值(除了自动增长主键外),如果不赋值,则会数据库中会被设置为NULL(注意是否 ...

  2. JS-011-颜色进制转换(RGB转16进制;16进制转RGB)

    在网页开发的时候,经常需要进行颜色设置,因而经常需要遇到进行颜色进制转换的问题,例如:RGB转16进制:16进制转RGB),前几天在测试的时候,发现网站的颜色进制转换某类16进制颜色(例如:#0000 ...

  3. python 操作消息队列

    图示 其中P指producer,即生产者:C指consumer,即消费者.中间的红色表示消息队列,实例中表现为HELLO队列. 往队列里插入数据前,查看消息队列 $sudo rabbitmqctl l ...

  4. MetInfo数据库结构表

    met_admin_table 表 Key 字段名称 数据类型 不为空 默认值 说明 PK id INT(11) Yes   编号   admin_type TEXT Yes   管理员类型   ad ...

  5. 使用Java字节流拷贝文件

    本文给出使用Java字节流实现文件拷贝的例子 package LearnJava; import java.io.*; public class FileTest { public static vo ...

  6. 关于Thread.getContextClassLoader的使用场景问题

    Thread context class loader存在的目的主要是为了解决parent delegation机制下无法干净的解决的问题.假如有下述委派链: ClassLoader A -> ...

  7. 完全偶图K(3,3)与完全图K5是否存在平面表示

    本文论述k(3, 3)与K5平面表示的存在性.首先给出图的平面表示的定义: 若可以在平面里画出一个图而让边没有任何交叉(边的交叉是指边的直线或弧线在它们的公共端点以外的地方相交),则这个图是平面性的. ...

  8. Adobe CS6 全系列官方下载地址 (迅雷无效) Win Mac

    https://helpx.adobe.com/x-productkb/policy-pricing/cs6-product-downloads.html CS6 Design & Web P ...

  9. W3cshool之JavaScript基础

        1.  JavaScript 对大小写敏感 名为 "myfunction"的函数和名为 "myFunction" 的函数是两个不同的函数,同样,变量 & ...

  10. innerHTML

    对于innerHTML 属性,几乎所有的元素都有innerHTML属性,它是一个字符串,用来设置或获取位于对象起始和结束标签内的HTML.(获取HTML当前标签的起始和结束里面的内容) 下面的例子返回 ...