RegisterAction.java
资源名称:Ajax.rar [点击查看]
上传用户:sz_mindeo
上传日期:2015-07-22
资源大小:913k
文件大小:1k
源码类别:
Ajax
开发平台:
Java
- package com.haiku.struts;
- 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.ActionForm;
- import org.apache.struts.action.ActionForward;
- import org.apache.struts.action.ActionMapping;
- import org.springframework.context.support.ClassPathXmlApplicationContext;
- import com.haiku.bean.Testuser;
- import com.haiku.bean.TestuserDAO;
- import com.haiku.form.RegisterForm;
- public class RegisterAction extends Action
- {
- public ActionForward execute(
- ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response
- )
- throws Exception
- {
- RegisterForm myform = (RegisterForm)form;
- Testuser transientInstance = new Testuser(myform.getUserName(),myform.getPassword());
- ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
- TestuserDAO dao =(TestuserDAO)context.getBean("user");
- String flag = dao.save(transientInstance);
- if(flag.equals("注册成功"))
- {
- request.setAttribute("userName", myform.getUserName());
- List list = dao.findAll();
- request.setAttribute("userList", list);
- return mapping.findForward("success");
- }
- else
- {
- return mapping.findForward("failure");
- }
- }
- }