public String findCommentByNewsId(String id) { Integer i = Integer.parseInt(id); System.out.println("service = " + new CommentDao().findCommentByNewsId(i).toString()); System.out.println("serviceGson = " + new Gson().toJson(new CommentDao().findCommentByNewsId(i))); return new Gson().toJson(new CommentDao().findCommentByNewsId(i)); }
public List<Comment> findCommentByNewsId(int id){ System.out.println("dao = " + Comment.dao.find("select * from comment_info where comment_belone = ?",id).toString()); return Comment.dao.find("select * from comment_info where comment_belone = " + id); }
dao = [Comment{comment_id=null, comment_author=null, comment_class=null, comment_content='null', comment_likeNum=null, comment_time=null, comment_belone=null}, Comment{comment_id=null, comment_author=null, comment_class=null, comment_content='null', comment_likeNum=null, comment_time=null, comment_belone=null}] service = [Comment{comment_id=null, comment_author=null, comment_class=null, comment_content='null', comment_likeNum=null, comment_time=null, comment_belone=null}, Comment{comment_id=null, comment_author=null, comment_class=null, comment_content='null', comment_likeNum=null, comment_time=null, comment_belone=null}] serviceGson = [{"attrs":{"comment_likenum":12,"comment_time":"十一月 27, 2019","comment_belone":1,"comment_author":1,"comment_class":3,"commentId":1,"comment_content":"涌起的情绪一言两语说不清楚,惊喜中带着不置信,随之而来的感动。"}},{"attrs":{"comment_likenum":23,"comment_time":"十一月 28, 2019","comment_belone":1,"comment_author":1,"comment_class":3,"commentId":2,"comment_content":"涌起的情绪一言两语说不清楚,惊喜中带着不置信,随之而来的感动。"}}]
转JSON的时候他居然能在控制台输出出来数据,但是两个调用toString方法打印出来的却是null
public class Comment extends Model<Comment>{ private Integer commentId; private Integer comment_author; private Integer comment_class; private String comment_content; private Integer comment_likeNum; private Date comment_time; private Integer comment_belone; public static final Comment dao = new Comment().dao(); public Comment(){} public Integer getCommentId() { return commentId; } public void setCommentId(Integer comment_id) { this.commentId = comment_id; }
项目:JFinal