📄 studentaction.java
字号:
package cn.com.tarena.web.struts.day3.lookup.action;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.LookupDispatchAction;
import cn.com.tarena.web.struts.day3.biz.StudentBiz;
import cn.com.tarena.web.struts.day3.pojo.Student;
public class StudentAction extends LookupDispatchAction {
protected Map getKeyMethodMap() {
Map keyMethodMap = new HashMap();
keyMethodMap.put("login.button.login", "login");
keyMethodMap.put("login.button.delete", "delete");
return keyMethodMap;
}
public ActionForward login(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String userName = request.getParameter("userName");
String password = request.getParameter("password");
StudentBiz studentBiz = new StudentBiz();
Student student = studentBiz.getStudent(userName, password);
if(student != null){
//找到学生
request.setAttribute("student", student);
return mapping.findForward("welcome");
}
return mapping.findForward("fail");
}
public ActionForward logout(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
return mapping.findForward("login");
}
public ActionForward delete(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
return mapping.findForward("deleted");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -