短学期SSH项目杂谈
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了短学期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类代码如下:
<!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>
以上是关于短学期SSH项目杂谈的主要内容,如果未能解决你的问题,请参考以下文章