搭建ssh1步骤

web.xml里面:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
 
 <!--监听spring  -->
 <listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <!-- 加载spring配置文件 -->
  <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath*:**/spring-*.xml</param-value>
  </context-param>
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>com.cvicse.cmstest.common.web.control.ActionServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>classpath*:**/struts-*.xml</param-value>
    </init-param>
    <init-param>
      <param-name>debug</param-name>
      <param-value>3</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>3</param-value>
    </init-param>
    <load-on-startup>0</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>


logfj4:
log4j.rootLogger = debug,  stdout 


log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target = System.out
log4j.appender.stdout.Threshold = warn 
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern =%d{yyyy-MM-dd HH:mm:ss,SSS} [%p] -%l -%m%n


spring-common-dao:
<?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:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="DaoSupport" abstract="true">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
</beans>
spring-datasource:
<?xml version="1.0" encoding="GBK"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.mysql.jdbc.Driver">
</property>
<property name="url"
value="jdbc:mysql://localhost:3306/ssh?useUnicode=true&amp;characterEncoding=GBK">
</property>
<property name="username" value="root"></property>


<property name="password" value="sun"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingLocations">
<list>
<value>classpath*:com/cvicse/cmstest/pojo/*.hbm.xml</value>
</list>
</property>
</bean>




<!-- 配置事务处理 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!--设置service层 事务处理的方法 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="save*" />
<tx:method name="add*" />
<tx:method name="query*" />
<tx:method name="delete*" />
<tx:method name="update*" />
<tx:method name="load*" />
</tx:attributes>
</tx:advice>


<aop:config>
<aop:pointcut id="DAOServicePointcut"
expression="execution(* com.cvicse.cmstest.*.service.impl.*.*(..))" />
<aop:advisor advice-ref="txAdvice"
pointcut-ref="DAOServicePointcut" />
</aop:config>


</beans>
spring的配置文件的配法:
?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:aop="http://www.springframework.org/schema/aop"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">




<!--DAO层类-->
<bean id="pcDAO"
class="com.cvicse.cmstest.baseData.dao.Impl.PcDAOImpl"
parent="DaoSupport">
</bean>
<!--service层类-->


<bean id="pcService"
class="com.cvicse.cmstest.baseData.service.impl.PcServiceImpl">
<property name="pcDAO" ref="pcDAO"></property>
</bean>
<!--action层类-->
<bean name="/pcinfo"
class="com.cvicse.cmstest.baseData.action.TestAction">
<property name="pcService" ref="pcService"></property>
</bean>


</beans>
struts1的配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd">


<struts-config>
  <form-beans>
   <form-bean name="sh1Bean" type="org.apache.struts.action.DynaActionForm">
  <form-property name="sh1Bean" type="com.cvicse.cmstest.baseData.dto.SH1Bean"></form-property>
  </form-bean>
  </form-beans>
  <global-exceptions />
  <global-forwards />
  <action-mappings>
  <action parameter="method" name="sh1Bean"
path="/pcinfo" scope="request" type="com.cvicse.cmstest.baseData.action.TestAction">
<forward name="SUCCESS" path="/Test.jsp"/>
<forward name="ADDSUCCESS" path="/addsuccess.jsp"/>
</action>
 
  </action-mappings>
  <controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor"></controller>
  <message-resources parameter="com.yourcompany.struts.ApplicationResources" />
</struts-config>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值