xmlns:
xsi="http:
//www.w3.org/2001/XMLSchema-instance"
xsi:
schemaLocation="
contextConfigLocation
classpath*:
applicationContext*.xml
--防止发生java.beans.Introspector内存泄露,
应将它配置在ContextLoaderListener的前面-->
--详细描述见
-->
org.springframework.web.util.IntrospectorCleanupListener
--实例化Spring容器-->
--
应用启动时,该监听器被执行,它会读取Spring相关配置文件,
其默认会到WEB-INF中查找applicationContext.xml
-->
org.springframework.web.context.ContextLoaderListener
--配置编码过滤器-->
characterEncodingFilter
org.springframework.web.filter.CharacterEncodingFilter
encoding
UTF-8
forceEncoding
true
characterEncodingFilter
/*
--配置spring管理OpenEntityManagerInViewFilter-->
--
OpenEntityManagerInViewFilter会让
session一直到view层调用结束后才关闭
Spring针对Hibernate的非JPA实现用的是OpenSessionInViewFilter,
原理与这个大同小异
-->
hibernateFilter
org.springframework.orm.jpa.support
.OpenEntityManagerInViewFilter
hibernateFilter
/*
--Shirofilter-->
--
这里filter-name必须对应applicationContext.xml中定义的
-->
shiroFilter
org.springframework.web.filter.DelegatingFilterProxy
--
该值缺省为false,表示生命周期由SpringApplicationContext管理,
设置为true则表示由ServletContainer管理
-->
targetFilterLifecycle
true
shiroFilter
/*
--
配置Log4j把log4j的默认配置文件(log4j.properties)放在classpath中,
通常是/web-inf/classes目录下.这种方式是log4j的默认配置方式,
无须其他配置。
缺点就是无法灵活的通过配置文件来指定log4j.properties的文件位置
webAppRootKey是log4j在容器中的唯一标识,缺省为"webapp.root"
-->
--
webAppRootKey
spring_springmvc_jpa.root
log4jConfigLocation
classpath:
log4j.properties
org.springframework.web.util.Log4jConfigListener
-->
--SpringMVC核心分发器-->
dispatcherServlet
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:
spring-mvc.xml
1
dispatcherServlet
/
login.jsp
--默认欢迎页-->
--
Servlet2.5中可直接在此处执行Servlet应用,如
servlet/InitSystemParamServlet
-->
--
这里使用了SpringMVC提供的view-controller>标签,
实现了首页隐藏的目的,详见spring-mvc.xml
-->
--
login.jsp
-->
applicationContext.xml
xmlversion="1.0"encoding="UTF-8"?
>
//www.springframework.org/schema/beans"
xmlns:
xsi="http:
//www.w3.org/2001/XMLSchema-instance"
xmlns:
aop="http:
//www.springframework.org/schema/aop"
xmlns:
tx="http:
//www.springframework.org/schema/tx"
xmlns:
context="http:
//www.springframework.org/schema/context"
xmlns:
p="http:
//www.springframework.org/schema/p"
xmlns:
cache="http:
//www.springframework.org/schema/cache"
xmlns:
jaxws="http:
//cxf.apache.org/jaxws"
xsi:
schemaLocation="http:
//www.springframework.org/schema/beanshttp:
//www.springframework.org/schema/beans/spring-beans-3.1.xsd
http:
//www.springframework.org/schema/txhttp:
//www.springframework.org/schema/tx/spring-tx-3.1.xsdhttp:
//www.springframework.org/schema/aophttp:
//www.springframework.org/schema/aop/spring-aop-3.1.xsd
http:
//www.springframework.org/schema/context
http:
//www.springframework.org/schema/context/spring-context-3.1.xsd
http:
//www.springframework.org/schema/cache
http:
//www.springframework.org/schema/cache/spring-cache-3.1.xsd
http:
//cxf.apache.org/jaxws
http:
//cxf.apache.org/schemas/jaxws.xsd">
--注解支持-->
annotation-config/>
--启动组件扫描,排除@Controller组件,该组件由SpringMVC配置文件扫描-->
component-scanbase-package="org.shiro.demo">
exclude-filter
type="annotation"expression="org.springframework.stereotype.Controller"/>
component-scan>
--属性文件位置-->
property-placeholder
location="classpath:
jdbc.properties"/>
--数据源-->
class="com.jolbox.bonecp.BoneCPDataSource"
destroy-method="close">
--数据库驱动-->
--相应驱动的jdbcUrl-->
--数据库的用户名-->
--数据库的密码-->
--JPA实体管理器工厂-->
"org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
ref="hibernateJpaVendorAdapter"/>
--加入定制化包路径-->
thread
update
--validate/update/create-->
false
false
--建表的命名规则-->
org.hibernate.cfg.ImprovedNamingStrategy
--设置JPA实现厂商的特定属性-->
"org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
value="${hibernate.dialect}"/>
--事务管理器-->
"org.springframework.orm.jpa.JpaTransactionManager">
ref="entityManagerFactory"/>
--注解式事务-->
annotation-driventransaction-manager="txManager"/>
spring-mvc.xml
18px">
xmlversion="1.0"encoding="UTF-8"?
>
//www.springframework.org/schema/beans"
xmlns:
mvc="http:
//www.springframework.org/schema/mvc"
xmlns:
xsi="http:
//www.w3.org/2001/XMLSchema-instance"
xmlns:
context="http:
//www.springframework.org/schema/context"
xsi:
schemaLocation="
http:
//www.springframework.org/schema/beans
http:
//www.springframework.org/schema/beans/spring-beans-3.1.xsd
http:
//www.springframework.org/schema/context
http:
//www.springframework.org/schema/context/spring-context-3.1.xsd
http:
//www.springframework.org/schema/mvchttp:
//www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
--启用SpringMVC的注解功能,它会自动注册
HandlerMapping、HandlerAdapter、ExceptionResolver的相关实例-->
annotation-driven/>
--SpringMVC的扫描范围-->
component-scanbase-package="org.shiro.demo.controller"/>
--默认访问跳转到登录页面,即定义无Controller的path<->view直接映射-->
view-controllerpath="/"view-name="redirect:
/login"/>
--静态文件访问-->
resourcesmapping="/resources/**"location="/resources/"/>
--配置SpringMVC的视图解析器-->
--其viewClass属性的默认值就是
org.springframework.web.servlet.view.JstlView-->
"org.springframework.web.servlet.view.InternalResourceViewResolver">
--value="org.springframework.web.servlet.view.JstlView"/>-->
--配置SpringMVC的异常解析器-->
"org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
--发生授权异常时,跳到指定页-->
"org.apache.shiro.authz.UnauthorizedException">
/system/error
--SpringMVC在超出上传文件限制时,会抛出org.springframework.web.multipart.MaxUploadSizeExceededException-->
--遇到MaxUploadSizeExceededException异常时,自动跳转到/WEB-INF/error_fileupload.jsp页面-->
--WEB-INF/error_fileupload-->
ehcache-shiro.xml
18px">
xmlversion="1.0"encoding="UTF-8"?
>
//ww