adteacheraction.java
来自「这是一个可以让学生选择自己喜欢的课题」· Java 代码 · 共 95 行
JAVA
95 行
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.yourcompany.struts.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.yourcompany.struts.form.AdteacherForm;
import allBeans.Teachers;
import allDAOFactory.ITeacherDAO;
/**
* MyEclipse Struts
* Creation date: 07-22-2008
*
* XDoclet definition:
* @struts.action path="/adteacher" name="adteacherForm" input="/Administrators/adteacher.jsp" scope="request" validate="true"
*/
public class AdteacherAction extends Action {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
AdteacherForm adteacherForm = (AdteacherForm) form;// TODO Auto-generated method stub
String th_id=adteacherForm.getTh_id();
String th_name=adteacherForm.getTh_name();
String th_sex=adteacherForm.getTh_sex();
ActionErrors errors=new ActionErrors();
ITeacherDAO thdao=new ITeacherDAO();
Teachers teacher=new Teachers();
boolean b_error=false;
if(th_id==null || th_id.equals(""))
{
errors.add("th_id",new ActionMessage("adteacher.th_id.wrong"));
b_error=true;
}
if(th_name==null || th_name.equals(""))
{
errors.add("th_name",new ActionMessage("adteacher.th_name.wrong"));
b_error=true;
}
if(th_sex==null || th_sex.equals(""))
{
errors.add("th_sex",new ActionMessage("adteacher.th_sex.wrong"));
b_error=true;
}
teacher=thdao.thget(th_id);
if(teacher!=null)
{
errors.add("adteacheristhid",new ActionMessage("adteacher.isthid.wrong"));
b_error=true;
}
if(!b_error)
{
teacher=new Teachers();
teacher.setThId(th_id);
teacher.setThName(th_name);
teacher.setThPassword(th_id);
teacher.setThSex(th_sex);
thdao.thsave(teacher);
adteacherForm.setTh_id("");
adteacherForm.setTh_name("");
adteacherForm.setTh_sex(null);
}
else
this.saveErrors(request, errors);
List list=thdao.thget();
request.setAttribute("thlist", list);
return mapping.findForward("toadteacher");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?