我通常使用控制器在我的jsp requestScopes中添加對象。如何在Spring的所有頁面中存儲變量requestScopes
例如,如果我需要列出類別在「本地主機/產品/ viewall」,我只是改變我的ProductsController添加類似
@RequestMapping("/products/viewall")
public void viewCategories(Model model) {
List<Category> categories = service.findAllCategories();
model.addAttribute("categories", categories);
}
所以,這種方法增加了分類列表我requestScope。
我需要做同樣的事情,但對於網站的所有頁面(因爲我需要的變量將用於網站的佈局)。
如何在Spring的所有頁面中添加requestScopes?