【问题标题】:Build url with 'sec:authentication="name"'使用 'sec:authentication="name"' 构建 url
【发布时间】:2015-02-14 12:37:48
【问题描述】:

我想知道是否有可能构建 url。

我用什么:

  • 弹簧靴 + 弹簧安全
  • 百里香

通过下面的表达式,我得到了用户名

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

有什么建议吗?

提前致谢。

【问题讨论】:

    标签: spring spring-security thymeleaf


    【解决方案1】:

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

    你的网址应该是:

    &lt;a th:href="@{|~/${#authentication.name}/edit|}" class="text-left"&gt;Settings&lt;/a&gt;

    【讨论】:

      猜你喜欢
      • 2020-11-13
      • 1970-01-01
      • 2016-11-16
      • 2018-05-19
      • 2017-04-14
      • 1970-01-01
      • 2016-04-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多