May 2015
Intermediate to advanced
234 pages
4h 18m
English
In this recipe, we'll see how to call a DAO method from a controller class.
We will use the DAO class defined in the previous recipe and pretend that it has an add(User) method. In the following recipes, we will write actual DAO methods.
Here are the steps to use a DAO method from a controller class:
@Autowired field:@Controller
public class UserController {
@Autowired
private UserDAO userDAO;
userDAO.add(user);Because of @Autowired, the userDAO field will be automatically initialized by Spring using dependency injection.
Read now
Unlock full access