dimanche 17 février 2019

Java If-statement doesn't work with .equals

I'm doing a web project with Spring-MVC and My-Batis, and i got a problem with a object i can print but cant use it in If-Statement, here's codes

User user = session.selectOne(statement, user_login_map);//this code is for MyBatis
out.print(user);//out is PrintWriter

The result shows on web-page is "yes", and ajax read the result is "yes" too.

But change code to if statement it can't work

  if (user.equals("yes")) {
                out.print(user);
            }

The result shows on web-page is nothing, which means it didn't run if and the result is null.

How to make this if work?

Aucun commentaire:

Enregistrer un commentaire