⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 registeraction.java

📁 该在线考试关系统(B/S结构)主要采用JAVA语言开发涉及主要WEB技术有:Struts+Spring+Hibernate框架
💻 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 + -