ssh实例

来源:互联网 发布:oppo手机解锁软件 编辑:程序博客网 时间:2024/05/09 17:36

本人搞ssh(spring 1.3,hibernate 3.2,stuts1.3)搞了一天半才搞出来,发现有个包一定要删除掉。引进来真的会害死人。

这个包是asm-2.2.3.jar

现将主要配置文件附上,

struts-config.xml

<?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="userinfoform" type="com.dg.form.UserInfoActionForm"></form-bean>
  </form-beans>
  <global-exceptions />
  <global-forwards />
  <action-mappings>
   <action path="/Find" input="/index.jsp" scope="request"  name="userinfoform" type="com.dg.action.UserInfoAction" >
          <forward name="user" path="/index.jsp" />
          <forward name="sucess" path="/sucess.jsp"></forward>
   </action>
  </action-mappings>
    <controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor" />
  <message-resources parameter="com.yourcompany.struts.ApplicationResources" />
   <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
    <set-property property="contextConfigLocation" value="classpath:applicationContext.xml"/>
  </plug-in>
</struts-config>

 

 

ApplicationContext.xml

<?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="dataSource"
  class="org.apache.commons.dbcp.BasicDataSource">
  <property name="driverClassName"
   value="com.microsoft.sqlserver.jdbc.SQLServerDriver">
  </property>
  <property name="url"
   value="jdbc:sqlserver://127.0.0.1:1433;databaseName=MyOffice">
  </property>
  <property name="username" value="sa"></property>
  <property name="password" value="123"></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.SQLServerDialect
    </prop>
    <prop key="hibernate.show_sql">true</prop>
    <prop key="hibernate.format_sql">true</prop>
   </props>
  </property>
  <property name="mappingDirectoryLocations">
  <list>
   <value>classpath:com/dg/entities</value>
  </list>
  </property>
 </bean>
 <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  <property name="sessionFactory">
   <ref local="sessionFactory" />
  </property>
 </bean>
 <bean id="userinfoDaoProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
  <property name="transactionManager">
   <ref bean="transactionManager" />
  </property>
  <property name="target">
   <ref local="userInfoDao" />
  </property>
  
  <property name="transactionAttributes">
   <props>
    <prop key="insert*">PROPAGATION_REQUIRED</prop>
    <prop key="update*">PROPAGATION_REQUIRED</prop>
    <prop key="*">PROPAGATION_REQUIRED</prop>
   </props>
  </property>
 </bean>
 <bean id="userInfoDao" class="com.dg.hibernateDao.UserInfoDao">
 <property name="sessionfactory"  ref="sessionFactory" />  
 </bean>
 <bean name="/Find" class="com.dg.action.UserInfoAction">
  <property name="userdao" ref="userinfoDaoProxy"></property>
 </bean>
 </beans>

哈哈,第一次搞ssh,写下来,以后参巧下。

原创粉丝点击