ssh 搭建

来源:互联网 发布:java工程师的简历模板 编辑:程序博客网 时间:2024/05/22 07:56

------- android培训、java培训、期待与您交流! ----------

 

struts2:
 web程序的框架.
 基于filter=StrutsPreparedAndExecuteFilter.
 struts1 + webwork ;
 耦合度松(和servlet api)
 分离关注:sperate aware,拦截器(aop),更加整洁mvc框架.
 action:原型,线程安全(threadlocal,数据安全).独占.
 
 synchronized:同步.

spring:业务层的框架,
 ioc:inverse of control,反转控制.获得依赖对象的方式.容器
  DI:dependency injection,依赖注入.
 aop:aspect oriented program,面向切面编程.不改变源代码,还增加新功能。
     aspect:切面
  通知:
  连接点:
  切入点:真正的
  目标对象:
  代理:
    jdk动态代理-接口代理,松耦合.
    cglib      -对类代理,final
 
  service层面事务管理.aop,环绕.

  事务属性:5
  1.传播行为.
  2.隔离级别:脏读 | 不可重复读 | 幻读(虚读)
     1:读未提交
     2:读已提交  oracle
     4:可以重复读 mysql
     8:串行化
  3.只读:优化
  4.超时:释放资源
  5.回滚规则:

  advice:MethodBeforeAdvice|AfterReturiningAdvice|MethodInterceptor,行为
  pointcut:切入点.
  advisor:切入点 + 通知
hibernate:
 持久化技术,封装了数据访问细节,体现了oop.hql
 ORM:object relation mapping.

搭建项目:
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
   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
dom4j-1.6.1.jar
freemarker-2.3.18.jar
hibernate3.jar
javassist-3.11.0.GA.jar
jta-1.1.jar
log4j.jar
ognl-3.0.4.jar
slf4j-api-1.5.8.jar
slf4j-log4j12.jar
struts2-core-2.3.1.2.jar
xwork-core-2.3.1.2.jar
 spring
com.springsource.net.sf.cglib-2.2.0.jar
com.springsource.org.aopalliance-1.0.0.jar
com.springsource.org.apache.commons.logging-1.1.1.jar
 com.springsource.org.aspectj.tools-1.6.6.RELEASE.jar
com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar
  
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
 driver
mysql-connector-java-5.0.8-bin.jar
 dataSource
com.springsource.com.mchange.v2.c3p0-0.9.1.2.jar
 struts2-spring整合:
struts2-spring-plugin-2.3.1.2.jar
3.创建包结构
 cn.itcast.dao.impl
 cn.itcast.domain
 cn.itcast.service.impl
 cn.itcast.struts2.action
 cn.itcast.util
4.创建配置
 struts
 ---------------------
  [web.xml]
  <!-- 通过上下文参数指定spring指定配置文件的位置 -->
  <context-param>
   <param-name>contextConfigLocation</param-name>
   <param-value>classpath:beans.xml</param-value>
  </context-param>
  <!-- 配置spring上下文载入器监听器,确保服务器启动时同时完成spring容器的初始化,放到Application范围中 -->
  <listener>
   <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  
  <!-- 配置struts2过滤器 -->
  <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>

  [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="test" namespace="/" extends="struts-default">
   
   </package>
  </struts>

 spring
 ---------------------
 <?xml version="1.0"?>
 <beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:tx="http://www.springframework.org/schema/tx"
  xmlns:context="http://www.springframework.org/schema/context"
  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/tx
       http://www.springframework.org/schema/tx/spring-tx-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/aop
       http://www.springframework.org/schema/aop/spring-aop-3.0.xsd ">

  <!-- 指定分散配置的文件 -->
  <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="hibernateProperties">
    <props>
     <prop key="hibernate.dialect">${hibernate.dialect}</prop>
     <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2dd.auto}</prop>
     <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
    </props>
   </property>
   <!-- 映射目录位置集 -->
   <property name="mappingDirectoryLocations">
    <list>
     <value>classpath:cn/itcast/surveypark/domain</value>
    </list>
   </property>
  </bean>
  <!-- hibernate事务管理器,在service层面上实现事务管理,到达平台无关性 -->
  <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
   <property name="sessionFactory" ref="sessionFactory" />
  </bean>
  
  <!-- 事务通知 -->
  <tx:advice id="txAdvcie" 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="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="txAdvcie" pointcut="execution(* *..*Service.*(..))"/>
  </aop:config>
 </beans>

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 老师罚做60张试卷家长该怎么办 孩子在幼儿园被老师打该怎么办 孩子被孩子打了老师该怎么办? 法院判决书下来后看守所不收怎么办 因病看守所不收押发院判了怎么办 现在显示还在看守所羁押需要怎么办 嫖了N多年丈夫让我怎么办 预约考试的登录密码忘了怎么办 人进了看守所信用卡没还怎么办 上海租房人放2个麻将台怎么办 南宁公租房住满5年后怎么办 合伙买房时如果出售意见不合怎么办 老旧小区改造下水一楼不同意怎么办 老旧小区下水改造没改怎么办 替公司租房子中介不退押金怎么办 想在昆山找合租房的该怎么办 链家二手房价钱买贵了怎么办 拿私人房产证抵押借钱不还怎么办 在借贷宝里借钱不还怎么办 出租屋的大门感应钥匙弄丢了怎么办 法院拍卖的房子房主不配合怎么办 租的房子如果房主卖了怎么办 房东把门锁换了里面的东西怎么办 房租没到期房东把门锁换了怎么办 租了三年店面房东违反了合同怎么办 学生登录教务系统的密码忘记怎么办 铜陵无牌助力车被交警查到怎么办 福州超标电动车被交警抓到怎么办 单位自管公租房承租人去世怎么办 取得房产证后贷款批不下来怎么办 租店面遇到难搞的房东怎么办 在拆违通知书上签字了该怎么办 单位没交公职金的退休后怎么办 公租房合同到期后没有续签怎么办 租房合同没到期不想租了怎么办 租的房子是人家公租房怎么办 五险合一软件口令忘记了怎么办 计生办把婚育状况登记错了怎么办? 医院发票法院要保险也要怎么办 上海社保里生育险暂停参保怎么办? 痔疮手术后大姨妈来了怎么办