81,092
社区成员
发帖
与我相关
我的任务
分享
<%@ page language="java" pageEncoding="utf-8" %>
<%@ page import="java.sql.*,java.util.*,com.xyz.bean.*" %>
<%
String path = request.getContextPath();
String basepath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
String username = request.getParameter("username");
String password = request.getParameter("password");
if( username == null || "".equals(username.trim()) || password == null || "".equals(password.trim())){
System.out.println("用户名或者密码不能为空!");
response.sendRedirect("login.jsp");
}
UserBean userbean = new UserBean();
boolean isValid = userbean.valid(username,password);
if (isValid){
System.out.println("登录成功!");
session.setAttribute("username",username);
response.sendRedirect("welcome.jsp");
}else {
System.out.println("用户名或密码错误,登录失败!");
response.sendRedirect("login.jsp");
}%>