{"id":9225,"date":"2024-05-07T19:01:01","date_gmt":"2024-05-07T11:01:01","guid":{"rendered":""},"modified":"2024-05-07T19:01:01","modified_gmt":"2024-05-07T11:01:01","slug":"\u57fa\u4e8ejavaweb\u7684\u5de1\u66f4\u5de1\u68c0\u7ba1\u7406\u7cfb\u7edf","status":"publish","type":"post","link":"https:\/\/mushiming.com\/9225.html","title":{"rendered":"\u57fa\u4e8ejavaweb\u7684\u5de1\u66f4\u5de1\u68c0\u7ba1\u7406\u7cfb\u7edf"},"content":{"rendered":"
\u7cfb\u7edf\u4e00\u5171\u5206\u4e3a3\u4e2a\u89d2\u8272\u5206\u522b\u662f\uff1a\u7ba1\u7406\u5458\uff0c\u7528\u6237\uff0c\u5de1\u66f4\u70b9<\/p>\n<\/p>\n
<\/p>\n
<\/p>\n
<\/p>\n
<\/p>\n
<\/p>\n
<\/p>\n
<\/p>\n
<\/p>\n
<%@ page language=\"java\" contentType=\"text\/html; charset=utf-8\"\n\tpageEncoding=\"utf-8\"%>\n\t <%@ taglib uri=\"http:\/\/java.sun.com\/jsp\/jstl\/core\" prefix=\"c\"%>\n\t\n<%\n\tString path = request.getContextPath();\n\tString basePath = request.getScheme() + \":\/\/\" + request.getServerName() + \":\" + request.getServerPort() + path + \"\/\";\n%>\n<!doctype html>\n<html lang=\"en\">\n<head>\n<!-- Required meta tags -->\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">\n\n<!-- Bootstrap CSS -->\n<link rel=\"stylesheet\" href=\"resource\/login\/bootstrap.min.css\">\n\n<!-- Loding font -->\n<link href=\"https:\/\/fonts.googleapis.com\/css?family=Montserrat:300,700\" rel=\"stylesheet\">\n\n<!-- Custom Styles -->\n<link rel=\"stylesheet\" type=\"text\/css\" href=\"resource\/login\/styles.css\">\n\n<title>\u5de1\u66f4\u7ba1\u7406\u7cfb\u7edf<\/title>\n<\/head>\n<body>\n\n<!-- Backgrounds -->\n\n<div id=\"login-bg\" class=\"container-fluid\">\n\n <div class=\"bg-img\"><\/div>\n <div class=\"bg-color\"><\/div>\n<\/div>\n\n<!-- End Backgrounds -->\n\n<div class=\"container\" >\n\t<div class=\"row justify-content-center\">\n\t<div class=\"col-lg-8\">\n\t <div class=\"login\" style=\"margin-top:200px;\">\n\n\t\t<h1>\u5de1\u66f4\u7ba1\u7406\u7cfb\u7edf\u767b\u5f55<\/h1>\n\t\t\n\t\t<!-- Loging form -->\n\t\t\t <form id=\"loginForm\" >\n\t\t\t\t<div class=\"form-group\">\n\t\t\t\t <input type=\"email\" class=\"form-control\" id=\"userName\" name=\"userName\" placeholder=\"\u624b\u673a\u53f7\u7801\u6216\u767b\u5f55\u8d26\u53f7\">\n\t\t\t\t \n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"form-group\">\n\t\t\t\t <input type=\"password\" class=\"form-control\" name=\"password\" id=\"password\" placeholder=\"\u8bf7\u8f93\u5165\u5bc6\u7801\">\n\t\t\t\t<\/div>\n\n\t\t\t\t <div class=\"form-check\">\n\n\t\t\t\t\t<!-- <label class=\"switch\">\n\t\t\t\t\t <input type=\"checkbox\">\n\t\t\t\t\t <span class=\"slider round\"><\/span>\n\t\t\t\t\t<\/label> -->\n\t\t\t\t <select name=\"type\" id=\"type\" class=\"form-control\">\n\t\t\t\t\t\t\t\t\t\t\t<option value=\"1\">\u7ba1\u7406\u5458<\/option>\n\t\t\t\t\t\t\t\t\t\t\t<option value=\"2\">\u7528\u6237<\/option>\n\t\t\t\t\t\t\t\t\t\t\t<option value=\"3\">\u5de1\u66f4\u70b9<\/option>\n\t\t\t\t\t\t\t\t\t\t<\/select> \n\t\t\t\t <!-- <label class=\"form-check-label\" for=\"exampleCheck1\">Remember me<\/label>\n\t\t\t\t \n\t\t\t\t <label class=\"forgot-password\"><a href=\"#\">Forgot Password?<a><\/label> -->\n\n\t\t\t\t<\/div>\n\t\t\t \n\t\t\t\t<br>\n\t\t\t\t<button type=\"button\" id=\"login\" class=\"btn btn-lg btn-block btn-success\">\u767b\u5f55<\/button>\n\t\t\t <\/form>\n\t\t <!-- End Loging form -->\n\n\t <\/div>Copyright © 2022.Company name All rights reserved.\n\t<\/div>\n\t<\/div>\n<\/div>\n<script src=\"layui\/jquery-1.9.1.min.js\"><\/script>\n<script src=\"layui\/layui.js\"><\/script>\n\n<script>\n\n\n$(\"#login\").on(\"click\", function() {\n var userName = $(\"#userName\").val().trim(); \/\/ trim()\u53bb\u9664\u7a7a\u683c\n var password = $(\"#password\").val().trim();\n var type = $(\"#type\").val();\n \n \n if(userName == \"\"){\n \t\n \talert('\u7528\u6237\u540d\u6216\u8005\u624b\u673a\u53f7\u4e0d\u80fd\u4e3a\u7a7a\uff01');\n \treturn false;\n }\n if(password == \"\"){\n \talert('\u5bc6\u7801\u4e0d\u80fd\u4e3a\u7a7a\uff01');\n \treturn false;\n }\n if(type == \"\"){\n \talert('\u8bf7\u9009\u62e9\u89d2\u8272\uff01');\n \treturn false;\n }\n \n $.ajax({\n\t\tcache : true,\n\t\ttype : \"post\",\n\t\turl : \"LoginServlet?action=login\",\n\t\tdata : $(\"#loginForm\").serialize(),\n\t\tasync : false,\n\t\tsuccess : function(e) {\n\t\t\tif (e == 'yes') {\n\t\t\t\talert(\"\u767b\u5f55\u6210\u529f\uff01\");\n\t\t\t\twindow.parent.location.href = \"LoginServlet?action=toMain\";\n\t\t\t}else {\n\t\t\t\talert(\"\u767b\u5f55\u5931\u8d25\uff0c\u8d26\u53f7\u6216\u8005\u5bc6\u7801\u9519\u8bef\uff01\");\n\t\t\t}\n\t\t}\n\t})\n\n});\n\n<\/script>\n<\/body>\n<\/html><\/code><\/pre>\nprotected void login(HttpServletRequest request, HttpServletResponse response) throws Exception {\/\/\u8df3\u8f6c\u5230\u6dfb\u52a0\u7528\u6237\u754c\ufffd?\n\t String userName = request.getParameter(\"userName\");\n String password = request.getParameter(\"password\");\n String type = request.getParameter(\"type\");\n String message = \"no\";\n\t if(type != null && type.equals(\"1\")){\/\/admin\n\t \tAdmin admin = service.selectAdmin(userName,password);\n\t \t if (admin != null) {\n\t \t\t message = \"yes\";\n\t \t\t request.getSession().setAttribute(\"flag\",1);\n\t request.getSession().setAttribute(\"admin\",admin);\n }\n\t \t \n\t }else if(type != null && type.equals(\"2\")){\n\t \tUser user = service.seletUser(userName,password);\n\t \t if (user != null) {\n\t \t\t message = \"yes\";\n\t \t\t request.getSession().setAttribute(\"flag\",2);\n\t request.getSession().setAttribute(\"user\",user);\n }\n\t \t \n\t }else if(type != null && type.equals(\"3\")){\n\t \tPoint point = service.selectPoint(userName,password);\n\t \t if (point != null) {\n\t \t\t message = \"yes\";\n\t \t\t request.getSession().setAttribute(\"flag\",3);\n\t request.getSession().setAttribute(\"point\",point);\n }\n\t \t \n\t }\n\t response.getWriter().print(message);\n\t}<\/code><\/pre>\n\u5176\u4ed6\u76f8\u5173\u4ee3\u7801\u90fd\u662f\u7c7b\u4f3c\u7684\uff0c\u4e3b\u8981\u662f\u524d\u7aefjsp\u548c\u540e\u7aefservlet\u4ea4\u4e92\u6bd4\u8f83\u91cd\u8981\uff01\uff01\uff01\u975e\u5f00\u6e90\uff01\uff01\uff01\uff01\uff01\uff01
\u5176\u4ed6\u6a21\u5757\u4ee3\u7801\u90fd\u662f\u7c7b\u4f3c\u7684\uff0c\u6b64\u9879\u76ee\u9002\u5408\u521d\u5b66\u8005\u5b66\u4e60\u501f\u9274\uff0c\u9879\u76ee\u6574\u4f53\u6bd4\u8f83\u7b80\u5355
\u559c\u6b22\u7684\u670b\u53cb\u7684\u70b9\u8d5e\u52a0\u5173\u6ce8\uff0c\u611f\u5174\u8da3\u7684\u540c\u5b66\u53ef\u4ee5\u7814\u7a76\uff01\uff01\uff01\uff01\uff01
\u611f\u8c22 = v =<\/h4>\n\u9879\u76ee\u622a\u56fe\u4e2d\u7684\u6570\u636e\uff0c\u5f88\u591a\u662f\u7528\u6765\u6d4b\u8bd5\u7684\uff0c\u9700\u8981\u81ea\u884c\u6dfb\u52a0\u5408\u9002\u7684\u6570\u636e\u56fe\u7247\uff01\uff01<\/span><\/h4>\n","protected":false},"excerpt":{"rendered":"\u57fa\u4e8ejavaweb\u7684\u5de1\u66f4\u5de1\u68c0\u7ba1\u7406\u7cfb\u7edf\u57fa\u4e8ejavaweb\u7684\u5de1\u66f4\u5de1\u68c0\u7ba1\u7406\u7cfb\u7edf\uff0c\u91c7\u7528eclipse\u5f00\u53d1\u5de5\u5177\uff0c\u7ed3\u5408\u524d\u7aeflayui+jquery+css\uff0c\u4f7f\u7528jsp+se...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/9225"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=9225"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/9225\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=9225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=9225"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=9225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}