search

Home  >  Q&A  >  body text

A problem encountered during a small example of javabean+jsp

About a problem encountered during a small example of javabean jsp
There is no connection error in the database, and index.jsp can also be displayed. . .
Please help the newbies to answer~~... ...under the guidance of my little brother...^ ^
Thank you very much ~! !

Jump to login.jsp
Why is a null pointer error reported?

sql table


The code is as follows:

index.jsp

login.jsp

UserService.java

User.java

Conn.java

巴扎黑巴扎黑2728 days ago845

reply all(2)I'll reply

  • 欧阳克

    欧阳克2017-06-12 09:22:10


    user is empty, username and password cannot be obtained

    In this case, you have written the logic of data submission in jsp, but the background does not receive it. You can write it in action or controller

    User u = new User();
    u.setUsername(request.getParameter("username"));
    u.setPassword(request.getParameter("password"));
    
    调用service并传参就ok了
    
    

    reply
    0
  • 漂亮男人

    漂亮男人2017-06-12 09:22:10

    Personally, I think a checkInput should be added first to determine whether it is the data passed by the login form? Otherwise, it will be null at the beginning when the page is rendered?

    1. String name=request.getPamareter("name");
      if(name=="loin"){//It should be login

    ............
    }

    reply
    0
  • Cancelreply