s2sh的注册与登录系列七

本文详细介绍了Struts框架的配置用法,并与Spring框架进行整合,包括配置文件的详细解析,如struts.xml、web.xml和applicationContext.xml等文件的配置,以及如何通过这些配置实现业务逻辑的调用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  下面将是struts.xml,web.applicationContext.xml,web.xml文件的配置用法,照样可以从例子中获取:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
 <constant name="struts.i18n.encoding" value="GBK"></constant>
 <constant name="struts.custom.i18n.resources" value="resources"></constant>
 <constant name="struts.objectFactory" value="spring"></constant>

 <constant name="struts.action.extension" value="bit,action,do"></constant>
 <constant name="struts.enable.DynamicMethodInvocation" value="true"></constant>
 <constant name="struts.devMode" value="false"></constant>
 <constant name="struts.configuration.xml.reload" value="true"></constant>

 <package name="personxml" namespace="/person" extends="struts-default">
  <global-results>
   <result type="redirectAction">/error.jsp</result>
  </global-results>


  <action name="person_*" class="mypersonaction" method="{1}">


   <result name="suc">
    /success.jsp
            </result>
   <result name="input">
    /error.jsp
            </result>
   <result name="sucinsert">
    /successinsert.jsp
             </result>
   <result name="failureinsert">
    /failureinsert.jsp
        </result>


  </action>
 </package>

 

</struts>

 

 

 

 

 

 

 

 

 

 

 

 

 

<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"
 xmlns:context="http://www.springframework.org/schema/context"
 xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
 xsi:schemaLocation="
   http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
   http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
   http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
   http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
  destroy-method="close">
  <property name="driverClassName">
   <value>com.mysql.jdbc.Driver</value>
  </property>
  <property name="url">
   <value>jdbc:mysql://localhost:3306/s2sh</value>
  </property>
  <property name="username">
   <value>root</value>
  </property>
  <property name="password">
   <value>root</value>
  </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>
    <prop key="hibernate.connection.autocommit">true</prop>
   </props>
  </property>
  <property name="mappingResources">
   <list>
    <value>com/hp/shangtongwei/vo/person.hbm.xml</value>

   </list>
  </property>

 </bean>

 <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
  <property name="sessionFactory">
   <ref bean="sessionFactory" />
  </property>
 </bean>
 <bean id="mypersonservice" class="com.hp.shangtongwei.serviceimpl.personserviceimpl">
  <property name="hibernateTemplate">
   <ref bean="hibernateTemplate" />
  </property>
 </bean>

 <bean name="mypersonaction" class="com.hp.shangtongwei.action.personaction"
  scope="prototype" autowire="byName">
  <property name="mypersonservice">
   <ref bean="mypersonservice" />
  </property>
 </bean>

 

 

 

 

</beans>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

<?xml version="1.0" encoding="

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值