If you are using Spring 3, the easiest way is:
@RequestMapping(method = RequestMethod.GET)
public ModelAndView showResults(final HttpServletRequest request, Principal principal) {
final String currentUser = principal.getName();
}
More Related Contents:
- Spring Security : Multiple HTTP Config not working
- Filter invoke twice when register as Spring bean
- How to get active user’s UserDetails
- How to disable spring security for particular url
- Difference between Role and GrantedAuthority in Spring Security
- Disable Spring Security for OPTIONS Http Method
- How to enable HTTP response caching in Spring Boot
- RESTful Authentication via Spring
- HttpSecurity, WebSecurity and AuthenticationManagerBuilder
- How to get the current logged in user object from spring security?
- Spring webSecurity.ignoring() doesn’t ignore custom filter
- Spring security does not allow CSS or JS resources to be loaded
- how to display custom error message in jsp for spring security auth exception
- spring web, security + web.xml + mvc dispatcher + Bean is created twice
- How to apply Spring Security filter only on secured endpoints?
- Spring Security HTTP Basic for RESTFul and FormLogin (Cookies) for web – Annotations
- Spring security added prefix “ROLE_” to all roles name?
- Why this Spring application with java-based configuration don’t work properly
- Spring REST security – Secure different URLs differently
- Custom Authentication Manager with Spring Security and Java Configuration
- Spring MVC: How to return custom 404 errorpages?
- Serializing enums with Jackson
- Spring Boot and custom 404 error page
- How to include js and CSS in JSP with spring MVC
- How to implement pagination in Spring MVC 3 [closed]
- Expose all IDs when using Spring Data Rest
- Spring security’s SecurityContextHolder: session or request bound?
- Can you completely disable CORS support in Spring?
- Spring MVC 4: “application/json” Content Type is not being set correctly
- Trigger 404 in Spring-MVC controller?