registeraction.java
来自「该在线考试关系统(B/S结构)主要采用JAVA语言开发涉及主要WEB技术有:St」· Java 代码 · 共 111 行
JAVA
111 行
/*
* 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 + =
减小字号Ctrl + -
显示快捷键?