我正在做类似 twitters 仪表板系统的事情来改进我的 Java Faces 知识。我有一个叫做 dashborad 的问题。我需要在索引中发布帖子以显示登录用户关注的人。就像 Facebook 的墙或 Twitters 仪表板一样。我做了一些事情。但我有一个错误。它是 NullerPointerException。这是我的代码:这是我的模型代码。这是从数据库中获取关注者。
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");
}
}
这是我在仪表板类中的 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;
}
- *我在仪表板类中有以下整数数组 *
- 另外,在 DashboardClass 中发布 ArrayList 我的错误是什么?
感谢您帮助 最好的问候