双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

druid查询可以查询数据库,查出来不对,感觉不像乱码,但也不知道是啥,之前这这么写一直都没问题,求大佬帮帮我吧,真的不知道为什么这样,困惑了好几天了。绝望

wsxyerr wsxyerr 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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]]


...全文
评论 7
收藏 已收藏
分享
返回顶部
wsxyerr
Web开发应用服务器 5,657 成员 20,155 内容