日期:2014-05-17  浏览次数:20776 次

ssh整合问题 从一个action访问另一个action报错
这两天练习ssh整合,做了一个小例子遇到了问题。
环境: myeclipse8.6 + tomcat7
整合的例子是 struts2.1 + spring 2.0 + hibernate3.3
所有的支持时用myeclipse的可视化工具添加的。


看配置文件:
struts.xml
XML code

<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>



applicationContext.xml
XML code

<?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>



loginAction.java
Java code

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