开发者

how to take username using security:authentication tag in Spring?

开发者 https://www.devze.com 2023-02-01 23:45 出处:网络
I am new to spring. I want send username of logged in user to my controller. I tried following code which is not working...

I am new to spring. I want send username of logged in user to my controller. I tried following code which is not working...

<form:input path="bidderName" value="<security:au开发者_开发问答thentication property=/"principal.username/"/>" />

at value field I want to take username of logged in user. Please Help. Thank you in Advance.


You don't need to send it to your Spring Controller. You can actually access it directly from there.

SecurityContextHolder.getContext().getAuthentication().getName();

It seems you're trying to pass the logged-in user from a JSP form back to your controller

0

精彩评论

暂无评论...
验证码 换一张
取 消