我正在做一些像twitters仪表板系统来改善我的Java Faces knowladge。我有一个名为dashborad的问题。我需要在索引中发布帖子来显示登录用户后面的人。像Facebook的墙壁或Twitters仪表板。我做了一些事情。但是我有一个错误。它是一个NullerPointerException.Here是我的代码: 这是我的模型代码。它是数据库的追随者。
public void whoIFollow(int[] list) throws SQLException {
MembersModel person = new MembersModel();
person.LoggedUserInfo(person.getSession());
long userid = person.getId();
Statement stat = (Statement) getConnect().createStatement();
ResultSet result = stat.executeQuery("SELECT * FROM `following` WHERE `follower_id`="+ userid); // Sorting following table which equals Logged Users id
int i = 0;
while (result.next()) {
list[i] = result.getInt("user_id");
i++;
}
if (i == 0) {
System.err.println("i sıfıra eşit");
}
}
这是Dashboard类中的getPosts方法:
public List<BlogPost> getPosts() throws SQLException {
FollowingModel test = new FollowingModel();
FollowingBlog post = new FollowingBlog();
try {
test.whoIFollow(followingList);
String following = null;
for (int i = 0; i < followingList.length; i++) {
if (i == followingList.length) {
following += followingList[i];
} else {
following += followingList[i] + ",";
}
}
post.listPost(posts, following);
} catch (NullPointerException e) {
System.err.println("Hataa");
}
return posts;
}
感谢您的帮助 最佳退伍军人