📄 login.java
字号:
/*
* Login.java
*
* Created on 2006年5月29日, 下午11:42
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package enova.web.struts.action;
import javax.servlet.http.*;
import org.apache.struts.action.*;
import enova.service.*;
import enova.pojo.*;
import enova.util.Const;
/**
*
* @author vlinux
*/
public class Login extends org.apache.struts.actions.DispatchAction {
private String username;
private String password;
private void loadForm(javax.servlet.http.HttpServletRequest request){
this.username = request.getParameter("username");
this.password = request.getParameter("password");
}
private String verify(HttpServletRequest request, String type){
loadForm(request);
try{
if(type.equals(Const.LOGIN_STUDENT)){
StudentService ss = (StudentService)ServiceFactory.makeService("StudentService");
Student student = ss.loginVerify(username,password);
request.getSession().setAttribute(Const.LOGIN_STUDENT,student);
return Const.LOGIN_STUDENT;
}else if(type.equals(Const.LOGIN_TEACHER)){
TeacherService ts = (TeacherService)ServiceFactory.makeService("TeacherService");
Teacher teacher = ts.loginVerify(username,password);
request.getSession().setAttribute(Const.LOGIN_TEACHER,teacher);
return Const.LOGIN_TEACHER;
}else{
RootService rs = (RootService)ServiceFactory.makeService("RootService");
Root root = rs.loginVerify(username,password);
request.getSession().setAttribute(Const.LOGIN_ROOT,root);
return Const.LOGIN_ROOT;
}
}catch(StoreException se){
request.setAttribute(Const.MESSAGES,"数据库出错");
return Const.STORE_EXCEPTION;
}catch(PasswordErrorException pee){
request.setAttribute(Const.MESSAGES,"拒绝登录");
return Const.ACCESS_DENY;
}
}
public ActionForward student(ActionMapping mapping, ActionForm actionForm,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
return mapping.findForward(verify(request,Const.LOGIN_STUDENT));
}
public ActionForward teacher(ActionMapping mapping, ActionForm actionForm,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
return mapping.findForward(verify(request,Const.LOGIN_TEACHER));
}
public ActionForward root(ActionMapping mapping, ActionForm actionForm,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
return mapping.findForward(verify(request,Const.LOGIN_ROOT));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -