关于ModelDriven怎么在同一个actiong中实现两个类的有关问题

关于ModelDriven怎么在同一个actiong中实现两个类的有关问题

关于ModelDriven如何在同一个actiong中实现两个类的问题
做一个登录系统,其中有教师登录和学生登录两个角色,我已经创建了teacher类和student类,想用ModelDriven传值到action,可是不知道应该怎样才能将这两个类同时实现,特来请教各位,我应该怎么做?下边附上源码
Teacher.java类
[code=text]package com.hp.exa.hibernate;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="student")
public class Student{

private String studentID;
private String password;
private String studentName;
private int result;
private String sclass;
@Id
@GeneratedValue
public String getStudentID() {
return studentID;
}
public void setStudentID(String studentID) {
this.studentID = studentID;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getStudentName() {
return studentName;
}
public void setStudentName(String studentName) {
this.studentName = studentName;
}
public int getResult() {
return result;
}
public void setResult(int result) {
this.result = result;
}
public String getSclass() {
return sclass;
}
public void setSclass(String sclass) {
this.sclass = sclass;
}


}
[/code]
Student.java类
package com.hp.exa.hibernate;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="teacher")
public class Teacher{
private String teacherID;
private String password;
@Id
@GeneratedValue
public String getTeacherID() {
return teacherID;
}
public void setTeacherID(String teacherID) {
this.teacherID = teacherID;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}

}

LoginAction.类
package com.hp.exa.action;

import com.hp.exa.dao.LoginDao;
import com.hp.exa.dao.impl.LoginDaoImpl;
import com.hp.exa.hibernate.Student;
import com.hp.exa.hibernate.Teacher;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;


public class LoginAction extends ActionSupport implements ModelDriven<Student>{

/**
 * 
 */
private static final long serialVersionUID = 1L;
private Teacher teacher;
private Student student;
private String role;

public String execute() {
if ("student".equals(role)) {
LoginDao logindao = new LoginDaoImpl();
if (logindao.studentlogin(student)) {
return "studentsuccess";
} else {
return ERROR;
}
}else if("teacher".equals(role)){
LoginDao logindao=new LoginDaoImpl();
if(logindao.teacherlogin(teacher)){
return "teachersuccess";
}else{
return ERROR;
}
}
return role;

}

@Override
public Student getModel() {
// TODO Auto-generated method stub
if (student == null) {
student = new Student();
}
return student;
}

public String getRole() {
return role;
}

public void setRole(String role) {
this.role = role;
}

}

------解决思路----------------------
再抽出来一个类,存放teacher和student对象,驱动这个类。