loginaction.java

来自「EXT技术的一个小项目(附源码和数据库脚本).rar,分图书管理」· Java 代码 · 共 50 行

JAVA
50
字号

package com.shyhao.qq.action;

import java.io.IOException;

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 com.shyhao.qq.service.LoginService;

public class LoginAction extends Action {

	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		String userName=request.getParameter("userName");
		String password=request.getParameter("password");
		LoginService lse=new LoginService();
		boolean exist=lse.checkLogin(userName, password);
		System.out.println(userName);
		System.out.println(password);
		System.out.println("exist :"+exist);
		response.setCharacterEncoding("UTF-8");
		try {
			if(exist){
				//response
				//request.setAttribute("userName",userName);
				//return mapping.findForward("chat");
			}else{
				response.getWriter().write("{'sucess':'false','message':'Failure'}");
			}
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		return null;
	}
}

⌨️ 快捷键说明

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