📄 registeraction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.laoniu.web.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
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 com.laoniu.bean.Customer;
import com.laoniu.common.BeanFactory;
import com.laoniu.common.exception.CustomerServiceException;
import com.laoniu.dao.ICustomerDao;
import com.laoniu.service.ICustomerService;
import com.laoniu.web.form.RegisterForm;
/**
* MyEclipse Struts
* Creation date: 04-27-2008
*
* XDoclet definition:
* @struts.action path="/register" name="registerForm" input="/register.jsp" scope="request" validate="true"
* @struts.action-forward name="success" path="/login.jsp"
* @struts.action-forward name="failure" path="/register.jsp"
*/
public class RegisterAction 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) {
RegisterForm registerForm = (RegisterForm) form;
//获得用户信息
String user=registerForm.getUser();
String password=registerForm.getPassword();
String email=registerForm.getEmail();
String address=registerForm.getAddress();
String zip=registerForm.getZip();
String telephone=registerForm.getTelephone();
//包装成类
Customer customer=new Customer();
customer.setName(user);
customer.setPassword(password);
customer.setEmail(email);
customer.setAddress(address);
customer.setZip(zip);
customer.setTelephone(telephone);
//调用dao接口
ICustomerService cs=(ICustomerService)BeanFactory.getBean(BeanFactory.CUSTOMERSERVICE);
try {
cs.register(customer);
HttpSession session=request.getSession(true);
session.setAttribute("successLogin","成功注册,请登录!");
return mapping.findForward("success");
} catch (CustomerServiceException e) {
request.setAttribute("error",e.getMessage());
return mapping.findForward("failure");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -