我正在使用java ee创建社交网络应用程序,并使用此错误在im堆栈中创建该方法getId()对于类型User未定义。这是我的用户模型
public class User {
private int id;
private String name;
private String surname;
private String email;
private String password;
private String avatar;
}
我在此类user.getId()中遇到此错误
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
HttpSession session = req.getSession();
String acceptId = req.getParameter("acceptId");
User user = (User) session.getAttribute("user");
friendRequestManager.acceptUserById(user.getId(), Integer.parseInt(acceptId));
req.getRequestDispatcher("/user/userHome").forward(req, resp);
}
```