package servlet;
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import Dao.DAO;
@WebServlet("/LoginServlet")
public class LoginServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
    public LoginServlet() {
        super();
        // TODO Auto-generated constructor stub
    }
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setHeader("Content-Type", "text/html;charset=utf-8");
		req.setCharacterEncoding("utf-8");//设置编码格式为utf-8
		String username = req.getParameter("username");
		String password = req.getParameter("password");
		String checkcode = req.getParameter("checkcode");
		String checkcode1 = (String) (req.getSession().getAttribute("checkcode"));
		System.out.println(username+" "+password+" "+checkcode+" "+checkcode1);
		PrintWriter out=resp.getWriter();
		if(checkcode1.equals(checkcode)==false) out.print("验证码错误");
		else if(!DAO.checkLogin(username, password)) out.print("账号或密码不匹配");
		else out.print("成功");
		

	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
最近下载更多
asddwh  LV12 1月3日
zhtssss  LV1 2023年7月4日
oracleanacarge  LV5 2023年7月3日
mrcao95  LV2 2023年6月26日
女王不该在山炮村养花  LV8 2023年4月16日
李亮  LV19 2023年3月6日
Numpile  LV3 2023年3月1日
poipoiiop  LV8 2023年1月3日
000666  LV10 2022年12月23日
微信网友_6263159342649344  LV7 2022年12月15日
最近浏览更多
周青松197  LV2 3月7日
asddwh  LV12 2023年12月29日
微信网友_6792227559149568 2023年12月24日
暂无贡献等级
颜菜菜  LV2 2023年12月23日
无名氏111  LV32 2023年11月14日
lyq6666666  LV5 2023年10月23日
jiemomo  LV12 2023年10月19日
qq573914838  LV5 2023年10月14日
lwlwlwlw  LV3 2023年9月25日
苏柒  LV10 2023年9月20日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友