Action层:
public class LoginAction {
private ISysUserBiz sysUserBiz;
private SysUser sysUser;
public String doLogin() {
System.out.println("进入doLogin()方法");
sysUser = sysUserBiz.findUser(sysUser.getUsrName(), sysUser
.getUsrPassword());
if (sysUser == null) {
return "login-failure";
}
HttpSession session = ServletActionContext.getRequest().getSession();
session.setAttribute("userSession", sysUser);
return "login-success";
}
}
Biz层:
public class SysUserBizImpl implements ISysUserBiz{
private ISysUserDao sysUserDao;
public SysUser findById(long id) {
return sysUserDao.findById(id);
}
public List<SysUser> findUsers(long id){
return sysUserDao.findUsers(id);
}
public SysUser findUser(String usrName, String usrPassword){
return sysUserDao.findUser(usrName, usrPassword);
}
/****************get*******set**********************/
public ISysUserDao getSysUserDao() {
return sysUserDao;
}
public void setSysUserDao(ISysUserDao sysUserDao) {
this.sysUserDao = sysUserDao;
}
}
Dao层:
public class SysUserDaoImpl extends HibernateDaoSupport implements ISysUserDao {
public SysUser findById(long id) {
return (SysUser) getHibernateTemplate().get(SysUser.class, id);
}
public List<SysUser> findUsers(long id) {
String hql = "from SysUser where usrFlag=" + id;
return getHibernateTemplate().find(hql);
}
public SysUser findUser(String usrName, String usrPassword) {
String hql = "from SysUser where usrName=? and usrPassword=?";
List<SysUser> users = getSession().createQuery(hql).setString(0,
usrName).setString(1, usrPassword).list();
if(users != null && users.size() >= 1){
return users.get(0);
}
return null;
}
}
<?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="sal" namespace="/html/~sale" extends="struts-default">
<action name="*-*" class="{1}Action" method="{2}">
<result name="success">{1}-{2}.jsp</result>
<result name="del-success">SaleChance-findAll.jsp</result>
<result name="save-success">SaleChance-findAll.jsp</result>
<result name="edit-success">SaleChance-findAll.jsp</result>
<result name="dispatch">dispatch.jsp</result>
<result name="do-edit">edit.jsp</result>
<result name="dev-success">dev_plan.jsp</result>
<result name="add-listplan">SalePlan-findAll.jsp</result>
<result name="dev-execute">dev_execute.jsp</result>
<result name="dev_detail">dev_detail.jsp</result>
</action>
</package>
<package name="customer" namespace="/html/~cust/cust" extends="struts-default">
<!-- 让struts到spring中找action对象 -->
<action name="*-*" class="{1}Action" method="{2}">
<result name="success">{1}-{2}.jsp</result>
<result name="success-toList" type="redirectAction">customer-findAll</result>
<result name="success-toLinkman" type="redirectAction">customer-linkman</result>
<result name="success-toActivity" type="redirectAction">customer-activities</result>
</action>
</package>
<package name="lost" namespace="/html/~cust/lost" extends="struts-default">
<!-- 让struts到spring中找action对象 -->
<action name="*-*" class="{1}Action" method="{2}">
<result name="success">{1}-{2}.jsp</result>
<result name="success-toList" type="redirectAction">lost-findAll</result>
</action>
</package>
<package name="service" namespace="/html/~cust/service" extends="struts-default">
<!-- 让struts到spring中找action对象 -->
<action name="*-*" class="{1}Action" method="{2}">
<result name="success">{1}-{2}.jsp</result>
<result name="add-success" type="redirectAction">service-add</result>
<result name="dispatch-success" type="redirectAction">service-dispatch</result>
<result name="deal-success" type="redirectAction">service-deal</result>
<result name="feedback-success" type="redirectAction">service-feedback</result>
<result name="delete-success" type="redirectAction">service-dispatch</result>
</action>
</package>
<package name="login" namespace="/" extends="struts-default">
<action name="*-*" class="{1}Action" method="{2}">
<result name="login-success" type="redirectAction">html/index.html</result>
<result name="login-failure" type="redirectAction">html/error.html</result>
</action>
</package>
</struts>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="connection.driver_class"> com.microsoft.sqlserver.jdbc.SQLServerDriver </property> <property name="connection.url"> jdbc:sqlserver://localhost:1433;databasename=jb_crm_team0 </property> <property name="connection.username">sa</property> <property name="connection.password">123</property> <property name="dialect"> org.hibernate.dialect.SQLServerDialect </property> <property name="show_sql">true</property> <property name="hbm2ddl.auto">update</property> <mapping resource="com/wepull/crm/domain/CstActivity.hbm.xml" /> <mapping resource="com/wepull/crm/domain/CstCustomer.hbm.xml" /> <mapping resource="com/wepull/crm/domain/CstLinkman.hbm.xml" /> <mapping resource="com/wepull/crm/domain/CstLost.hbm.xml" /> <mapping resource="com/wepull/crm/domain/Orders.hbm.xml" /> <mapping resource="com/wepull/crm/domain/OrdersLine.hbm.xml" /> <mapping resource="com/wepull/crm/domain/Product.hbm.xml" /> <mapping resource="com/wepull/crm/domain/CstService.hbm.xml" /> <mapping resource="com/wepull/crm/domain/BasDict.hbm.xml" /> <mapping resource="com/wepull/crm/domain/SalChance.hbm.xml" /> <mapping resource="com/wepull/crm/domain/SalPlan.hbm.xml" /> <mapping resource="com/wepull/crm/domain/Storage.hbm.xml" /> <mapping resource="com/wepull/crm/domain/SysRight.hbm.xml" /> <mapping resource="com/wepull/crm/domain/SysRole.hbm.xml" /> <mapping resource="com/wepull/crm/domain/SysRoleRight.hbm.xml" /> <mapping resource="com/wepull/crm/domain/SysUser.hbm.xml" /> </session-factory> </hibernate-configuration>
<?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:aop="http://www.springframework.org/schema/aop"
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.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<!-- 根据hibernate配置文档产生sessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<!-- 配置事务的传播特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="edit*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 配置哪些类的哪些方法进行事务管理 -->
<aop:config>
<aop:pointcut id="allManagerMethod" expression="execution(* com.wepull.crm.biz.*.*(..))"/>
<aop:advisor pointcut-ref="allManagerMethod" advice-ref="txAdvice"/>
</aop:config>
<!-- ***********************first model******************** -->
<!-- ***dao********************************************************* -->
<bean id="salchancedao" class="com.wepull.sale.dao.SalChanceDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="salplandao" class="com.wepull.sale.dao.SalPlanDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- ***biz************************************************************ -->
<bean id="salchancebiz" class="com.wepull.crm.biz.SalChanceBizImpl">
<property name="salchancedao" ref="salchancedao"></property>
</bean>
<bean id="salplanbiz" class="com.wepull.crm.biz.SalPlanBizImpl">
<property name="salplandao" ref="salplandao"></property>
</bean>
<!-- ***action********************************************************* -->
<bean id="SaleChanceAction" class="com.wepull.sale.action.SalChanceAction">
<property name="salchancebiz" ref="salchancebiz"></property>
</bean>
<bean id="SalePlanAction" class="com.wepull.sale.action.SalPlanAction">
<property name="salplanbiz" ref="salplanbiz" ></property>
<property name="salchancebiz" ref="salchancebiz"></property>
</bean>
<!-- ***********************first model******************** -->
<!-- ***********************second model******************** -->
<!-- dao层 start -->
<bean id="customerDao" class="com.wepull.crm.customer.dao.CustomerDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="orderDao" class="com.wepull.crm.customer.dao.OrderDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="lostDao" class="com.wepull.crm.customer.dao.LostDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- dao层 end -->
<!-- biz层 start-->
<bean id="customerBiz" class="com.wepull.crm.biz.CustomerBizImpl">
<property name="customerDao" ref="customerDao"></property>
</bean>
<bean id="orderBiz" class="com.wepull.crm.biz.OrderBizImpl">
<property name="orderDao" ref="orderDao"></property>
</bean>
<bean id="lostBiz" class="com.wepull.crm.biz.LostBizImpl">
<property name="lostDao" ref="lostDao"></property>
</bean>
<!-- biz层 end-->
<!-- action层 start-->
<bean id="customerAction" class="com.wepull.crm.customer.action.CustomerAction">
<property name="customerBiz" ref="customerBiz"></property>
</bean>
<bean id="orderAction" class="com.wepull.crm.customer.action.OrderAction">
<property name="orderBiz" ref="orderBiz"></property>
<property name="customerBiz" ref="customerBiz"></property>
</bean>
<bean id="lostAction" class="com.wepull.crm.customer.action.LostAction">
<property name="lostBiz" ref="lostBiz"></property>
</bean>
<!-- action层 end-->
<!-- ***********************second model******************** -->
<!-- ***********************third model******************** -->
<!-- dao层 start -->
<bean id="serviceDao" class="com.wepull.crm.dao.CstServiceDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="sysUserDao" class="com.wepull.crm.dao.SysUserDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- dao层 end -->
<!-- biz层 start-->
<bean id="serviceBiz" class="com.wepull.crm.biz.CstServiceBizImpl">
<property name="serviceDao" ref="serviceDao"></property>
</bean>
<bean id="sysUserBiz" class="com.wepull.crm.biz.SysUserBizImpl">
<property name="sysUserDao" ref="sysUserDao"></property>
</bean>
<!-- biz层 end-->
<!-- action层 start-->
<bean id="serviceAction" class="com.wepull.crm.action.ServiceAction">
<property name="serviceBiz" ref="serviceBiz"></property>
<property name="sysUserBiz" ref="sysUserBiz"></property>
</bean>
<bean id="sysUserAction" class="com.wepull.crm.action.SysUserAction">
<property name="sysUserBiz" ref="sysUserBiz"></property>
</bean>
<bean id="loginAction" class="com.wepull.crm.action.LoginAction">
<property name="sysUserBiz" ref="sysUserBiz"></property>
</bean>
<!-- action层 end-->
<!-- ***********************third model******************** -->
</beans>
3715

被折叠的 条评论
为什么被折叠?



