📄 dengluaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.zjy.struts.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.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import com.zjy.struts.form.DengluForm;
import com.zjy.struts.mypackage.DengluDao;
/**
* MyEclipse Struts Creation date: 04-06-2007
*
* XDoclet definition:
*
* @struts.action path="/denglu" name="dengluForm" input="/form/denglu.jsp"
* scope="request" validate="true"
*/
public class DengluAction 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) {
DengluForm dengluForm = (DengluForm) form;
// TODO Auto-generated
HttpSession hs = request.getSession();
String image = (String) hs.getAttribute("rand");
if (dengluForm.getYzm().equals(image)) {//判断密码
DengluDao dd = new DengluDao();
int rst = dd.denglu(dengluForm);
if (rst == 0) {//用户不存在
ActionErrors errors = new ActionErrors();
errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
"dengluwrong"));
this.addMessages(request, errors);
return mapping.getInputForward();
} else if(rst==1){//普通用户
hs.setAttribute("dname", dengluForm.getUsername());
request.setAttribute("inf", "1");
hs.setAttribute("keys","0");//普通用户标记
return mapping.findForward("tomessage");
}else{//管理员
hs.setAttribute("dname", dengluForm.getUsername());
hs.setAttribute("keys","1");//管理员标记
request.setAttribute("inf", "0");
return mapping.findForward("tomessage");
}
} else {//验证码出错
System.out.println("2");
ActionErrors errors = new ActionErrors();
errors.add("yzm", new ActionError("yzmwrong"));
this.saveErrors(request, errors);
return mapping.getInputForward();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -