日期:2014-05-17 浏览次数:20739 次
<package name="suibiaojiao" extends="struts-default" namespace="/"> <action name="login" class="loginAction"> <result name="ok">findAll.action</result> <result name="error">/error.jsp</result> </action> <action name="findAll" class="findAllAction"> <result name="ok">/studentList.jsp</result> <result name="error">/error.jsp</result> </action> </package>
<?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:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.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://127.0.0.1:3306"></property> <property name="username" value="root"></property> <property name="password" value="lm"></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configLocation" value="classpath:hibernate.cfg.xml"> </property> <property name="dataSource" ref="dataSource"></property> </bean> <bean id="studentDAO" class="com.lm.Impdao.StudentDAO"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <bean id="stuBiz" class="com.lm.Impbiz.StudentBiz"> <property name="stuDAO" ref="studentDAO"></property> </bean> <bean id="loginAction" class="com.lm.struts2.loginAction"> <property name="stuBiz" ref="stuBiz"></property> </bean> <bean id="findAllAction" class="com.lm.struts2.findAllAction"> <property name="stuBiz" ref="stuBiz"></property> </bean> </beans>
package com.lm.struts2; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.apache.struts2.ServletActionContext; import com.lm.biz.IStudentBiz; import com.lm.dao.Student; import com.opensymphony.xwork2.ActionSupport; public class loginAction extends ActionSupport { private Student stu; private IStudentBiz stuBiz; public void setStuBiz(IStudentBiz stuBi