第一:在mode层建立AppContext类
public class AppContext {
第二:在spring.xml中配置
<?xml version="1.0" encoding="UTF-8"?>
<beans
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
"
default-lazy-init="false" default-autowire="byName">
<bean id="appContext" class="orgx.prjx.dto.common.AppContext" scope="session">
<aop:scoped-proxy/>
</bean>
第三:在代码中使用
@Autowired
private AppContext appContext;
这样做的好处:就不用每次都获得session了。