loginaction.java

来自「达内JAVA培训-WEB课程部分项目源代码」· Java 代码 · 共 45 行

JAVA
45
字号
package cn.com.tarena.web.struts.day1.action;

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 cn.com.tarena.web.struts.day1.biz.StudentBiz;
import cn.com.tarena.web.struts.day1.pojo.Student;

public class LoginAction extends Action {
	
	public ActionForward execute(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");
	}

	
	
	
	
	
	
	
	
	
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?