我想知道是否有可能建立网址。
我用的是什么:
使用以下表达式,我得到用户名
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
有什么建议吗?
提前致谢。
答案 0 :(得分:4)
正如文档中所述:https://github.com/thymeleaf/thymeleaf-extras-springsecurity3
你的网址应该是:
<a th:href="@{|~/${#authentication.name}/edit|}" class="text-left">Settings</a>