三层的Helloworld程序

1、domain:存放数据

2、dao:

//把xml中的数据查询出来之后,封装到user对象中,
public User find(){
return new User("haha","123");
}

3、service:

private UserDao userdao=new UserDao();
public User find(){
return userdao.find();
}

 

4、web.servlet

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
UserService userService =new UserService();
User user=userService.find();
request.setAttribute("user", user);
request.getRequestDispatcher("/user.jsp").forward(request, response);

}

 

posted @ 2017-04-06 14:44  贱贱的小帅哥  阅读(147)  评论(0编辑  收藏  举报