📄 regaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.knt.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.knt.actionform.RegActionForm;
import com.knt.dao.UserServiceImpl;
import com.knt.interfaces.UserService;
import com.knt.pojo.Customer;
/**
* MyEclipse Struts
* Creation date: 04-09-2009
*
* XDoclet definition:
* @struts.action path="/regAction" name="indexActionForm" input="/reg.jsp" parameter="method" scope="request" validate="true"
* @struts.action-forward name="error" path="/error.jsp"
* @struts.action-forward name="success" path="/success.jsp"
*/
public class RegAction 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) {
RegActionForm regActionFrom = (RegActionForm)form;
Customer customer = new Customer();
customer.setName(regActionFrom.getUsername());
customer.setPassword(regActionFrom.getPassword());
customer.setSex(regActionFrom.getSex());
customer.setTel(regActionFrom.getTel());
customer.setAddr(regActionFrom.getAddr());
UserService dao = new UserServiceImpl();
try {
dao.addUser(customer);
HttpSession session = request.getSession();
session.setAttribute("user",customer);
return mapping.findForward("regsuccess");
} catch (Exception e) {
return mapping.findForward("regerror");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -