📄 studentaction.java
字号:
package cn.com.tarena.web.struts.day3.dispatch.action;
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.DispatchAction;
import cn.com.tarena.web.struts.day3.biz.StudentBiz;
import cn.com.tarena.web.struts.day3.pojo.Student;
public class StudentAction extends DispatchAction {
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");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -