为什么我收到此错误为什么类型为User的方法getId()未定义

时间:2019-06-01 22:50:31

标签: java java-ee

我正在使用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);
 } 
 ```

0 个答案:

没有答案