How to check “hasRole” in Java Code with Spring Security?
you can use the isUserInRole method of the HttpServletRequest object. something like: public String createForm(HttpSession session, HttpServletRequest request, ModelMap modelMap) { if (request.isUserInRole(“ROLE_ADMIN”)) { // code here } }