package com.hgq.student_information.web.struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.hgq.student_information.dao.DAOFactory;
import com.hgq.student_information.dao.TeacherDAO;
import com.hgq.student_information.domain.Student;
import com.hgq.student_information.domain.Teacher;
import com.hgq.student_information.web.struts.form.StudentForm;
import com.hgq.student_information.web.struts.form.TeacherForm;
public class EditTeacher extends Action{
private TeacherDAO teaDao;
public TeacherDAO getTeacherDAO() {
return DAOFactory.getInstance().createTeacherDAO();
}
/**
* Method execute
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String id = (String)request.getParameter("teacher_id");
/*
* 声明一个StudentForm类型的对象. form为页面中提交的表单信息,将它
* 强制转换为StudentForm类型,并赋值给stuForm对象
*/
TeacherForm teaForm = (TeacherForm) form ; // 错误代码
teaDao = this.getTeacherDAO();
// 根据ID获取学生信息
Teacher tea = teaDao.getTeacherByID(id);
// 设置相应的更新属性
tea.setName( teaForm.getName());
tea.setPassword( teaForm.getPassword());
tea.setXuebu( teaForm.getXuebu());
tea.setSex( teaForm.getSex() );
tea.setTitle(teaForm.getTitle());
tea.setTel( teaForm.getTel()) ;
tea.setEmail( teaForm.getEmail()) ;
if(teaDao.updateTeacher(tea)){
// 更新成功,跳转页面
return (mapping.findForward("success"));
}else {
return (mapping.getInputForward());
}
}
}
代码我已经继承Action类了..为什么还会出现这个错误...
最奇怪的是..之前有个类也是试用此代码..都没有错误.
就这个类的代码出现这个错误...
求高手解答..
估计是<action name="这个地方填错了。。">关键是你的TeacherForm 怎么写的,是集成了ActionForm吗?奇怪了,TeacherForm 和你的Action有啥关系