📄 loginaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package jhyy.login;
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 org.apache.struts.action.DynaActionForm;
import xiaoshou.classes.CUser;
import xiaoshou.javabeans.Operator;
public class LoginAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
DynaActionForm loginForm = (DynaActionForm) form;// TODO
String name = (String) loginForm.get("name");
String password = (String) loginForm.get("password");
String department = (String) loginForm.get("department");
String target = "error";
DBoperator dbp = new DBoperator();
switch (Integer.parseInt(department)) {
case 1:
if (dbp.login("customerinfo", name, password)) {
target = "customer";
request.getSession().setAttribute("name", name);
}
break;
case 2:
//String position=dbp.login2("sellers", name, password);
//if(null!=position) {
//target = "seller";
//request.getSession().setAttribute("name", name);
//request.getSession().setAttribute("position", position);
CUser user=Operator.checkLogin(name,password);
if(user!=null){
request.getSession(true).setAttribute("user",user);
target="seller";
}
break;
case 3:
String position=dbp.login2("center", name, password);
if(null!=position) {
target = "center";
request.getSession().setAttribute("name", name);
request.getSession().setAttribute("position", position);
}
break;
case 4:
if (dbp.login("warehousekeeper", name, password)) {
target = "cangku";
request.getSession().setAttribute("name", name);
}
break;
case 5:
if (dbp.login("chuyubu", name, password)) {
target = "chuyun";
request.getSession().setAttribute("name", name);
}
break;
default:
target = "";
}
return mapping.findForward(target);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -