Sagar
Sagar

Reputation: 1262

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

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:authentication property=/"principal.username/"/>" />

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

Upvotes: 1

Views: 956

Answers (1)

chris
chris

Reputation: 3858

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

Upvotes: 4

Related Questions