java - How to get logged user name/Principal in Spring MVC REST channel? -


i have spring mvc rest channel:

@controller @requestmapping("/rest") public class rest { 

and have method:

@requestmapping(value = "/dosomething") public @responsebody dosomethingresultdto dosomething(     @requestbody dosomethingrequestdto) 

now need name of user logged in. method

httpservletrequest.getuserprincipal() 

but how here? have annotations headers (@requestheader), or cookies (@cookievalue). how can principal in method?

you can inject principal object controller handler method

@requestmapping(value = "/dosomething") public @responsebody dosomethingresultdto dosomething(     @requestbody dosomethingrequestdto, principal principal) 

see the spring reference manual more info


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -