严重: useBean类属性[shl.test1.jsp.JspUserDao]的值无效

严重: 在路径为/201909250329的上下文中,Servlet[jsp]的Servlet.service()引发了具有根本原因的异常/301/login_act.jsp (行.: [4], 列: [1]) useBean类属性[shl.test1.jsp.JspUserDao]的值无效。 应该怎么解决

img

jsp代码

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
    <h1 align="center">系统登陆</h1>
    <form action="login_act.jsp" method="get">
        <table align="center">
            <tr>
                <td>用户名:</td>
                <td><input type="text" name="name"></td>
            </tr>
            <tr>
                <td>密码:</td>
                <td><input type="text" name="pwd"></td>
            </tr>
            <tr>
                <td><input type="submit" value="提交"></td>
            </tr>
        </table>
    </form>
    <%
        String info = (String) request.getAttribute("info");
    %>
    <%=info == null ? "" : info%>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <jsp:useBean id="user" class="shl.test1.jsp.JspUser"></jsp:useBean>
    <jsp:useBean id="dao" class="shl.test1.jsp.JspUserDao"></jsp:useBean>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
    <%    request.setCharacterEncoding("utf-8");
    String name = request.getParameter("name");
    String pwd =request.getParameter("pwd");
    if(name.equals("")||pwd.equals(""))
    {
        //name="";pwd="";
        request.setAttribute("info", "请输入用户名!");
        %>
        <jsp:forward page="login.jsp"></jsp:forward>
        <% 
    }
     user.setUsername(name);
    user.setPassword(pwd);
    
        if(!dao.login(user))
    {
            request.setAttribute("info", "用户名或密码错误!");
            %>
            <jsp:forward page="login.jsp"></jsp:forward>
            <% 
    } 
        else {
            session.setAttribute("user", user);
            response.sendRedirect("main.jsp");
        }
%>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@page import="shl.test1.jsp.JspUser"%>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="user" class="shl.test1.jsp.JspUser"></jsp:useBean>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
    <%
    user = (JspUser)session.getAttribute("user");
    if(user== null){
        request.setAttribute("info", "请登录!");
        %>
    <jsp:forward page="login.jsp"></jsp:forward>
    <% }
%>
    <input type="button" value="注销" onclick="window.location.href('outlogin.jsp')"    />
</body>
</html>
package shl.test1.jsp;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DbConnection {
    String url = "jdbc:mysql://localhost:3306/jsptest?"+"useUnicode=true&characterEncoding=UTF8";
    String user = "root";
    String password = "";
    static Connection conn ;
    public static Connection getConnection() {
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            System.out.println("Not find Driver!");
        }
        try {
            conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/jsptest","root","");
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            System.out.println("Not getConnection!");
        }
        System.out.println("Connection is success!");
        return conn;    
    }
    }
package shl.test1.jsp;

public class JspUser {
    private int id;
    private String username;
    private String email;
    private String password;
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    
}
package shl.test1.jsp;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

public class JspUserDao {
    Connection conn = DbConnection.getConnection();

    Statement sta;
    ResultSet rst;

    public boolean login(JspUser user) {
        String name = user.getUsername();
        String pwd = user.getPassword();
        String sql = "select * from jspuser where username='" + name + "'   and Password =   '" + pwd + "'  ";
        try {
            sta = conn.createStatement();
        } catch (SQLException e) {
            e.printStackTrace();
            System.out.println("sta is not correct ");
        }
        try {
            rst = sta.executeQuery(sql);
        } catch (SQLException e) {
            e.printStackTrace();
            System.out.println("rst is not correct ");
        }
        try {
            if (rst.next()) {
                System.out.println("-------login is success ! ");
                sta.close();
                rst.close();
                conn.close();
                return true;
            }

        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return false;
    }
}

img 这个user没看到创建或者声明啊