Issue
I would like to share my problem with you. I can't use two List in a function but when a remove a List the program success. My Code :
com.poly.dao.ProductDao dao;
com.poly.dao.CategoryDAO dao2;
ServletContext app;
@RequestMapping("/product/index")
public String index(Model model) {
com.poly.entity.Product item = new Product();
model.addAttribute("item",item);
List<Category> cate = dao2.findAll();
List<Product> items = dao.findAll();
model.addAttribute("items",items);
model.addAttribute("cate",cate);
return("admin/product/admin-add-product");
}
When I remove a List<Category> cate = dao2.findAll();
the program run but when I add this the program notices erro : java.lang.NullPointerException: Cannot invoke "com.poly.dao.CategoryDAO.findAll()" because "this.dao2" is null
I don't understand this erro. Anyone help my pls thanksss
Solution
Oh i found a solution for my code
I forgot write @Autowired
above dao and dao2.
This is a solution for code.
Answered By - sunsynd