我是春天新手。我想将登录用户的用户名发送到我的控制器。 我尝试使用不起作用的代码......
<form:input path="bidderName" value="<security:authentication property=/"principal.username/"/>" />
在值字段我想获取登录用户的用户名。 请帮忙。先谢谢你。
答案 0 :(得分:5)
您无需将其发送到Spring Controller。你可以直接从那里访问它。
SecurityContextHolder.getContext().getAuthentication().getName();
您似乎正在尝试将登录用户从JSP表单传递回控制器