使用'来构建网址:authentication =" name"'

时间:2014-12-16 08:42:56

标签: spring spring-security thymeleaf

我想知道是否有可能建立网址。

我用的是什么:

  • 春季靴子+弹簧安全
  • Thymeleaf

使用以下表达式,我得到用户名

sec:authentication="name"

如果我执行以下操作,将显示当前用户名

<span id="userName" sec:authentication="name">Testuser</span>

但现在我想建立一个类似以下的网址:

<a th:href="@{'~/' + __${{sec.authentication='name'}}__ + '/edit'}" class="text-left">Settings</a>

有了这个我得到以下错误:

org.springframework.expression.spel.SpelEvaluationException: EL1009E:(pos 4): Property or field 'authentication' cannot be set on null

有什么建议吗?

提前致谢。

1 个答案:

答案 0 :(得分:4)

正如文档中所述:https://github.com/thymeleaf/thymeleaf-extras-springsecurity3

你的网址应该是:

<a th:href="@{|~/${#authentication.name}/edit|}" class="text-left">Settings</a>

相关问题