微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ssh实例

本人搞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,写下来,以后参巧下。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐