调查管理系统(1)

调研系统,调查系统(调查页面,1.页标题,2.常规页,非常规页,高级页3.问题(问题类型:非矩阵,矩阵),答案) 4.(动态表单,如何统计数据 )5. 统计生成报表文件,分析     6.对可见的调查参加调查 7.用户角色

struts2开发  servlet--ActionServlet

开发web程序的框架,基于filter--StrutsPrepareAndExecuteFilter.
耦合度低:
1.原生servlet API
2.我们自己的类和struts2的api.
3.拦截器
分离关注:拦截器.
action:原型,有状态.独占,线程安全.相对的性能下降

hibernate持久化层

spring 业务层管理bean(默认是单例的,最好改为多例)

synchorized:锁
threadlocal:线程本地化.数据安全.

m:model,模型,携带数据.
v:view,显示层
c:controller.


单例:
多例:pool,池化技术.
原型:原始模型.
scope:singleton|prototype|request|session|global session


hibernate:
持久化技术,封装数据的访问细节(sql + ??),体现oop.
轻量级jdbc


spring:
业务层框架,管理bean的容器.
ioc:inverse of controller,获得依赖对象方式.
aop:面向切面编程,aspect oriented program
通知:前置 后置 环绕 异常 引入,
使用代理:1-jdk动态代理(接口代理) 2-cglib代理(final)
调查管理系统(1)_第1张图片

搭建项目:
1.创建web项目
2.引入类库
[struts2]
asm-3.3.jar
asm-commons-3.3.jar
asm-tree-3.3.jar
commons-fileupload-1.2.2.jar
commons-io-2.0.1.jar
commons-lang-2.5.jar
freemarker-2.3.18.jar
javassist-3.11.0.GA.jar
ognl-3.0.4.jar
struts2-core-2.3.1.2.jar
xwork-core-2.3.1.2.jar
[hibernate]
antlr-2.7.6.jar
commons-collections-3.1.jar
hibernate3.jar
javassist-3.11.0.GA.jar
jta-1.1.jar
log4j.jar
slf4j-api-1.5.8.jar
slf4j-log4j12.jar
[spring]
org.springframework.aop-3.1.0.RELEASE.jar
org.springframework.asm-3.1.0.RELEASE.jar
org.springframework.aspects-3.1.0.RELEASE.jar
org.springframework.beans-3.1.0.RELEASE.jar
org.springframework.context-3.1.0.RELEASE.jar
org.springframework.context.support-3.1.0.RELEASE.jar
org.springframework.core-3.1.0.RELEASE.jar
org.springframework.expression-3.1.0.RELEASE.jar
org.springframework.jdbc-3.1.0.RELEASE.jar
org.springframework.orm-3.1.0.RELEASE.jar
org.springframework.transaction-3.1.0.RELEASE.jar
org.springframework.web-3.1.0.RELEASE.jar

com.springsource.net.sf.cglib-2.2.0.jar
com.springsource.org.aopalliance-1.0.0.jar
com.springsource.org.aspectj.tools-1.6.6.RELEASE.jar
com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar
com.springsource.org.apache.commons.logging-1.1.1.jar
[struts-spring-plugin]
struts2-spring-plugin-2.3.1.2.jar
[driver]
mysql-connector-java-5.0.8-bin.jar
[datasource]
com.springsource.com.mchange.v2.c3p0-0.9.1.2.jar
3.创建包结构
cn.itcast.surveypark.dao
cn.itcast.surveypark.dao.impl
cn.itcast.surveypark.domain
cn.itcast.surveypark.service
cn.itcast.surveypark.service.impl
cn.itcast.surveypark.struts2.action
cn.itcast.surveypark.util
4.配置文件
[struts2]
1.web.xml
<!-- 配置struts2 filter -->
<filter>
<filter-name>action</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>action</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>


2.struts.xml:conf/struts.xml
<?xml version="1.0"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
"http://struts.apache.org/dtds/struts-2.1.7.dtd">
<struts>
<package name="surveyParkPkg" namespace="/" extends="struts-default">

</package>
</struts>

[hibernate]


[spring]
<?xml version="1.0"?>
<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:tx="http://www.springframework.org/schema/tx" 
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.0.xsd 
http://www.springframework.org/schema/tx 
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd 
http://www.springframework.org/schema/aop 
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd ">
<!-- 组件扫描 -->
<context:component-scan base-package="cn.itcast.surveypark.dao.impl,cn.itcast.surveypark.service.impl,cn.itcast.surveypark.struts2.action" />

<!-- 分散配置 -->
<context:property-placeholder location="classpath:jdbc.properties"/>

<!-- 数据源 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${jdbc.driverclass}" />
<property name="jdbcUrl" value="${jdbc.url}" />
<property name="user" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />

<property name="maxPoolSize" value="${c3p0.pool.size.max}" />
<property name="minPoolSize" value="${c3p0.pool.size.min}" />
<property name="initialPoolSize" value="${c3p0.pool.size.ini}" />
<property name="acquireIncrement" value="${c3p0.pool.size.increment}" />
</bean>

<!-- 本地会话工厂bean,spring整合hibernate的核心入口 -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- 注入数据源 -->
<property name="dataSource" ref="dataSource" />
<!-- 指定hibernate配置文件 -->
<property name="configLocation" value="classpath:hibernate.cfg.xml" />
<!-- 指定映射文件目录 -->
<property name="mappingDirectoryLocations">
<list>
<value>classpath:cn/itcast/surveypark/domain</value>
</list>
</property>
</bean>

<!-- 事务管理器,在service层面上实现事务管理,而且达到平台无关性 -->
<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 配置事务通知 -->
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="save*" propagation="REQUIRED" isolation="DEFAULT" />
<tx:method name="update*" propagation="REQUIRED" isolation="DEFAULT" />
<tx:method name="delete*" propagation="REQUIRED" isolation="DEFAULT" />
<tx:method name="batch*" propagation="REQUIRED" isolation="DEFAULT" />
<tx:method name="new*" propagation="REQUIRED" isolation="DEFAULT" />

<tx:method name="get*" propagation="REQUIRED" isolation="DEFAULT" read-only="true"/>
<tx:method name="load*" propagation="REQUIRED" isolation="DEFAULT" read-only="true"/>
<tx:method name="find*" propagation="REQUIRED" isolation="DEFAULT" read-only="true"/>

<tx:method name="*" propagation="REQUIRED" isolation="DEFAULT" />
</tx:attributes>
</tx:advice>

<!-- aop事务配置 -->
<aop:config>
<aop:advisor advice-ref="txAdvice" pointcut="execution(* *..*Service.*(..))"/>
</aop:config>
</beans>

调查管理系统(1)_第2张图片

你可能感兴趣的:(项目)