After setting up the SSH environment, the operation of customer information is realized:
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"
xsi:schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/ Spring-beans-2.0.xsd ">
<!--database-Configure Data connection pool--
<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:3306/dbssh" >
</property>
<property name= "username" value= "root" ></property>
<property name= "Password" value= "123456" ></property>
<property name= "maxactive" value= "></property>"
<property name= "maxwait" value= "></property>"
<property name= "Defaultautocommit" value= "true" ></property>
</bean>
<!--sessionfactory Configuration and management--
<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</value>
</list>
</property>
</bean>
<!--Configuring DAO--
<bean id= "Custdao" class= "Com.crm.impl.CustDaoImpl" >
<property name= "Sessionfactory" >
<ref bean= "Sessionfactory"/>
</property>
</bean>
<!--Configuration Service--
<bean id= "Custservice" class= "Com.crm.service.impl.CustServiceImpl" >
<property name= "Custdao" ref= "Custdao" ></property>
</bean>
<!--configuration-New Saveaction-
<bean id= "custsaveaction" class= "Com.crm.action.CustSaveAction" >
<property name= "service" ref = "Custservice" ></property>
</bean>
<!--configuration-query listcustaction-
<bean id= "listcustaction" class= "Com.crm.action.ListCustAction" >
<property name= "Custservice" ref= "Custservice" ></property>
</bean>
<!--configuration-delete deleteaction-
<bean id= "removecustaction" class= "Com.crm.action.RemoveCustAction" >
<property name= "service" ref= "Custservice" ></property>
</bean>
<!--configuration-conditional query findcdtaction-
<bean id= "findcdtaction" class= "Com.crm.action.FindCustByCdtAction" >
<property name= "Findcdtservice" ref= "Custservice" ></property>
</bean>
<!--configuration-typeaction--
<bean id= "typeaction" class= "Com.crm.action.TypeAction" >
</bean>
</beans>
Struts.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>
<!--Save-
<package name= "Customer" extends= "Struts-default" >
<action name= "Savecust" class= "Custsaveaction" >
<result name= "Input" >/custAdd.jsp</result>
</action>
<!--query-
<action name= "Listcust" class= "Listcustaction" >
<result>/jsp/custInfo.jsp</result>
</action>
<!--removed-
<action name= "Delectcust" class= "Removecustaction" >
<result>/jsp/custInfo.jsp</result>
</action>
<!--typeaction drop-down list--
<action name= "typeaction" class= "Typeaction" >
<result></result>
</action>
<!--conditions Query--
<action name= "findcdtcustlist" class= "Findcdtaction" >
<result>/jsp/custInfo.jsp</result>
</action>
</package>
</struts>
Information storage class Custsaveaction.java
Package com.crm.action;
Import Com.crm.bean.Cust;
Import Com.crm.service.CustService;
Import Com.opensymphony.xwork2.ActionSupport;
public class Custsaveaction extends actionsupport{
Private Custservice service;
Private Cust Cust;
Public Cust Getcust () {
Return Cust;
}
public void Setcust (Cust Cust) {
This.cust = Cust;
}
Public Custservice GetService () {
return service;
}
public void Setservice (Custservice service) {
This.service = Service;
}
@Override
Public String Execute () throws Exception {
TODO auto-generated Method Stub
This.service.saveCustomer (Cust);
return SUCCESS;
}
}
Information Removal class Removecustaction.java
Package com.crm.action;
Import Java.util.Map;
Import Com.crm.service.CustService;
Import Com.opensymphony.xwork2.ActionContext;
Import Com.opensymphony.xwork2.ActionSupport;
public class Listcustaction extends actionsupport{
/**
*
*/
Private static final long serialversionuid = 1L;
Private Custservice Custservice;
Public Custservice Getcustservice () {
return custservice;
}
public void Setcustservice (Custservice custservice) {
This.custservice = Custservice;
}
@SuppressWarnings ("Unchecked")
@Override
Public String Execute () throws Exception {
Map map = (map) actioncontext.getcontext (). Get ("request");
Map.put ("List", This.custService.findAllCust ());
return SUCCESS;
}
}
Query Findcustbycdtaction.java by criteria
Package com.crm.action;
Import Java.util.Map;
Import Com.crm.bean.Cust;
Import Com.crm.service.CustService;
Import Com.opensymphony.xwork2.ActionContext;
Import Com.opensymphony.xwork2.ActionSupport;
public class Findcustbycdtaction extends actionsupport{
Private Cust Cust;
Private Custservice Findcdtservice;
Public Cust Getcust () {
Return Cust;
}
public void Setcust (Cust Cust) {
This.cust = Cust;
}
Public Custservice Getfindcdtservice () {
return findcdtservice;
}
public void Setfindcdtservice (Custservice findcdtservice) {
This.findcdtservice = Findcdtservice;
}
@SuppressWarnings ({"Unchecked", "unchecked"})
@Override
Public String Execute () throws Exception {
TODO auto-generated Method Stub
Map map = (map) actioncontext.getcontext (). Get ("request");
Map.put ("List", This.findCdtService.findCustByCondition (Cust));
return SUCCESS;
}
}
Customer Information Maintenance JSP