logincheck.jsp

来自「可以实现一个文本框的搜索」· JSP 代码 · 共 36 行

JSP
36
字号
<%@page contentType="text/html;charset=gbk"%>
<%@page import="java.io.*,java.util.*,com.util.StringUtils" %>
<%

  FileInputStream istream = null;
  Properties props = new Properties();
  
  //String urlPath = request.getRealPath("/") + "WEB-INF/classes/sys_setting.properties";
  String urlPath = getServletContext().getRealPath("/") + "WEB-INF/classes/sys_setting.properties";
 
  out.print(urlPath);
  istream = new FileInputStream(urlPath);            
  props.load(istream);            
  istream.close(); 
  
  String username = props.getProperty("sys.admin.login.username");
  String password = props.getProperty("sys.admin.login.password");
                  
  String uid = StringUtils.parseString(request.getParameter("uid"));
  String pwd = StringUtils.parseString(request.getParameter("pwd"));
  
  
  
    if(uid.equals(username) && pwd.equals(password)) {
      props = null;
      session.setAttribute("loginSuccess","true");
      response.sendRedirect("adminHome.jsp");
    }
    
    else{
    	
      out.print("<script>alert('登陆失败');window.history.go(-1);</script>");
 
   }
 
%>

⌨️ 快捷键说明

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