From:http://stackoverflow.com/questions/3021200/how-to-check-hasrole-in-java-code-with-spring-security
1
|
1
2
3
4
5
6
7 |
public String createForm(HttpSession session, HttpServletRequest request, ModelMap modelMap) { if
(request.isUserInRole("ROLE_ADMIN")) { // code here }} |
2
|
1
2
3
4 |
HttpServletRequest req = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();SecurityContextHolderAwareRequestWrapper sc = new
SecurityContextHolderAwareRequestWrapper(req, "");SecurityContextHolderAwareRequestWrapper.isUserInRole(String role) |
How to check “hasRole” in Java Code with Spring Security?,布布扣,bubuko.com
How to check “hasRole” in Java Code with Spring Security?
原文:http://www.cnblogs.com/sun_moon_earth/p/3587667.html