How to check “hasRole” in Java Code with Spring Security?
From:http://stackoverflow.com/questions/3021200/how-to-check-hasrole-in-java-code-with-spring-security
1
public String createForm(HttpSession session, HttpServletRequest request,  ModelMap   modelMap) {
    if (request.isUserInRole("ROLE_ADMIN")) {
        // code here
    }
}
2
HttpServletRequest req = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest(); SecurityContextHolderAwareRequestWrapper sc = new SecurityContextHolderAwareRequestWrapper(req, ""); SecurityContextHolderAwareRequestWrapper.isUserInRole(String role)
 
                    
                     
                    
                 
                    
                 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号