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> ...
随机推荐
- 小吐槽Toolbar
最近弄界面 要吧全部图标改成PNG格式 虽说从2010以后Delphi默认支持PNG格式图片, 但是想应用到按钮上, 似乎除了TButton意外, 也只能ToolBar可以正常显示了, 其他的, 比如 ...
- 【爬虫】python之BeautifulSoup用法
1.爬虫 网络爬虫是捜索引擎抓取系统的重要组成部分.爬虫的主要目的是将互联网上的网页下载到本地形成一个或联网内容的镜像备份.通过分析和过滤HTML 代码,实现对图片.文字等资源的获取. 2.pytho ...
- oracle创建、删除账户
1.创建 /*第1步:创建表空间 */create tablespace xybi datafile 'E:\oracle\oradata\zzxe\xybi_d01' size 100M ; /*第 ...
- RDIFramework.NET Web版介绍
RDIFramework.NET Web版介绍 B/S结构(Browser/Server,浏览器/服务器模式),是WEB兴起后的一种网络结构模式,WEB浏览器是客户端最主要的应用软件.这种模式统一了 ...
- nodejs框架express准备登录
目录: 安装模板 静态资源 添加视图 渲染视图 url重定向 模板引擎 从本节课程开始我们要使用express框架实现一个简单的用户登陆功能,让我们先准备一下相关资源. 在nodejs中使用expre ...
- An internal error occurred during: "Building workspace".
当在eclipse中的web工程中增加了extjs4,出现An internal error occurred during: "Building workspace". Java ...
- SQL2005中的事务与锁定(四)- 转载
------------------------------------------------------------------------ -- Author : HappyFlyStone - ...
- asp.net 验证正则表达式
基本元字符: . 任意的一个非换行字符 [] 集合匹配,匹配一个[]中出现的字符. 是在多个字符中取一个. () 调整优先级的作用. 还有一个分组的作用 | 或的意思,测试|一下. 注意,或的优先级最 ...
- Android实现归属地查询功能
实现归属地查询大体有两种方法可以实现,一种是通过归属地API进行查询,另一种是查询本地数据库.两种方法各有优劣,最好结合起来使用,我本次采用的是查询数据库的方法.首先需要从网上下载归属地数据库call ...
- LR HTML与URL录制方式区别
Recording录制选项 这里提供了两个大类的录制方式: 1. HTML-based script基于HTML的脚本 这种方式录制出来的脚本是基于HTML基础的,为每个用户操作生成单独的步骤,这种脚 ...