📄 registeraction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package web.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import po.Ostudent;
import web.form.StudentRegForm;
import business.IStuService;
/**
* MyEclipse Struts
* Creation date: 01-15-2008
*
* XDoclet definition:
* @struts.action validate="true"
*/
public class RegisterAction extends DispatchAction
{
private IStuService stuService;
public IStuService getStuService()
{
return stuService;
}
public void setStuService(IStuService stuService)
{
this.stuService = stuService;
}
public ActionForward register(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
StudentRegForm Form = (StudentRegForm) form;
Ostudent stu = new Ostudent();
stu.setId(Form.getStudentid());
stu.setName(Form.getName());
stu.setPassword(Form.getPassword_());
stu.setSex(Form.getSex());
stu.setBirthday(Form.getBirthday());
stu.setTel(Form.getTel());
stu.setCollege(Form.getCollege());
if(stuService.judgeContain(stu.getId()))
{
stuService.addStudent(stu);
String username = stu.getId();
String password = stu.getPassword();
request.setAttribute("username", username);
request.setAttribute("password", password);
request.setAttribute("id_js", "able");
return mapping.findForward("stu_warn");
}
else
{
request.setAttribute("id_js", "unable");
return mapping.findForward("stu_warn");
}
}
public ActionForward preRegister(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
String id = request.getParameter("studentid");
if(!stuService.judgeContain(id))
{
request.setAttribute("id_ajax", "unable");
}
else
{
request.setAttribute("id_ajax", "able");
}
return mapping.findForward("stu_warn");
}
public ActionForward updateRegister(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
StudentRegForm Form = (StudentRegForm) form;
Ostudent stu = new Ostudent();
stu.setId(request.getParameter("id"));
stu.setName(Form.getName());
stu.setPassword(Form.getPassword_());
stu.setSex(Form.getSex());
stu.setBirthday(Form.getBirthday());
stu.setTel(Form.getTel());
stu.setCollege(Form.getCollege());
stuService.updataStudent(stu);
request.setAttribute("suc_js", "succeful");
return mapping.findForward("stu_warn");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -