📄 registeraction.java
字号:
package com.wish.jhk.action;
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 com.wish.jhk.action.form.RegisterForm;
import com.wish.jhk.service.impl.AuctionManagerImpl;
import com.wish.jhk.util.BeanFactory;
public class RegisterAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest req, HttpServletResponse resp) throws Exception {
ActionForward forward = new ActionForward();
RegisterForm registerform = (RegisterForm) form;
try {
AuctionManagerImpl auctionmanager = (AuctionManagerImpl) BeanFactory
.getBean("auctionmanager");
if (auctionmanager.validateRegister(registerform.getUsername()) != 1) {
auctionmanager.register(registerform.getUsername(),
registerform.getPassword(), registerform.getEmail());
forward.setPath("/registerSuccess.jsp");
} else {
req.setAttribute("message", "该用户名已存在");
forward.setPath("/register.jsp");
}
} catch (Exception e) {
e.printStackTrace();
req.setAttribute("exception", e.getMessage());
forward.setPath("/error.jsp");
}
return forward;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -