druid查询可以查询数据库,查出来不对,感觉不像乱码,但也不知道是啥,之前这这么写一直都没问题,求大佬帮帮我吧,真的不知道为什么这样,困惑了好几天了。绝望
servlet代码:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
//response.getWriter().append("Served at: ").append(request.getContextPath());
UserDaoImpl dao=new UserDaoImpl();
List<Login> user = dao.findAll();
System.out.println(user);
}
dao代码:
public class UserDaoImpl{
private JdbcTemplate jdbc=new JdbcTemplate(DruidUtil.getDataSource());
public List<Login> findAll() {
// TODO Auto-generated method stub
String sql="select * from user1";
List<Login> users = jdbc.query(sql, new BeanPropertyRowMapper<Login>(Login.class));
return users;
}
}
domain代码:
public class Login {
private String name;
private String password;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
结果查询出来是这个:
[jdbctest.Login@1b84aa37, jdbctest.Login@560f9a1b, jdbctest.Login@79e7f97e]
我也不知道是个啥东西。
查询出来正确的应该是这样的:
[Login [name=zhangsan, password=123], Login [name=张三, password=123], Login [name=lisi, password=123]]