短学期SSH项目杂谈

ssh工程下的子文件:

其中,application类中的代码如下
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.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:3306ssh">
</property>
<property name="username" value="root"></property>
<property name="password" value="123456"></property>
<property name="maxActive" value="100"></property>
<property name="maxWait" value="500"></property>
<property name="defaultAutoCommit" value="true"></property>
</bean>
<!--sessionFactory配置与管理  -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="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="mappingResources">
<list>
<value>com/crm/bean/Cust.hbm.xml<alue>
<st>
</property>
</bean>

<!--配置DAO  -->
<bean id="custDao" class="com.crm.impl.CustDaoImpl">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<!-- 配置service -->
<bean id="custService" class="com.crm.service.impl.CustServiceImpl">
<property name="custDao" ref="custDao"></property>
</bean>

<!-- 配置SaveAction -->
<bean id="custSaveAction" class="com.crm.action.CustSaveAction">
<property name="service">
<ref bean="custService"/>
</property>
</bean>

<!--配置-查询listAction  -->
<bean id="listCustAction" class="com.crm.action.CustListAction">
<property name="service" ref="custService"></property>
</bean>

<!--配置-删除deleteAction  -->
<bean id="custRemoveAction" class="com.crm.action.CustRemoveAction">
<property name="service" ref="custService"></property>
</bean>


<!--配置-条件查询findCdtAction  -->
<bean id="findCustByCdtAction" class="com.crm.action.FindCustByCdtAction">
<property name="findCdtService" ref="custService"></property>
</bean>

<!--配置-修改updateCustAction  -->
<bean id="updateCustAction" class="com.crm.action.UpdateCustAction">
<property name="updateCustService" ref="custService"></property>
</bean>
<!--配置-修改预览updatePreviewCustAction  -->
<bean id="updatePreviewCustAction" class="com.crm.action.UpdatePreviewCustAction">
<property name="updatePreviewCustService" ref="custService"></property>
</bean>
</beans>

用于配置各种action类,实现操作

 

struts类代码如下:

<?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>
<package name="customer" extends="struts-default">


<!-- 保存 -->
<action name="saveCust" class="custSaveAction">
<result name="success" type="redirect">/jsp/custInfo.jsp</result>
</action>

<!-- 查询 -->
<action name="listCust" class="listCustAction">
<result>/jsp/custInfo.jsp</result>
</action>

<!-- 删除 -->
<action name="delectCust" class="custRemoveAction">
<result>/jsp/custInfo.jsp</result>
</action>

<!-- 条件查询 -->
<action name="findCust" class="findCustByCdtAction">
<result>/jsp/custInfo.jsp</result>
</action>

<!-- 修改预览 -->
<action name="updatePreviewCust" class="updatePreviewCustAction">
<result name="success">/jsp/updateCust.jsp</result>
</action>

<!-- 修改 -->
<action name="updateCust" class="updateCustAction">
     <result name="success" type="redirect">listCustomer.action</result>
<result name="input">/jsp/updateCust.jsp</result>
</action>

</package>
</struts>
用于连接前端和后端

posted @ 2017-07-02 17:00  玩了个命  阅读(128)  评论(0编辑  收藏  举报