Jef*_*eff 5 spring-security thymeleaf
我在我的春季应用程序中使用安全性.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
这是我的登录控制器:
@Configuration
static class ClientWebConfig extends WebMvcConfigurerAdapter {
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/login").setViewName("fragments/login");
}
}
Run Code Online (Sandbox Code Playgroud)
然后我做了菜单,在那里我试着制作退出按钮:
<li th:if="${#authorization.expression('isAuthenticated()')}">
<a href="/logout" th:href="@{/logout}">Logout</a>
</li>
Run Code Online (Sandbox Code Playgroud)
我可以正确登录,但是当它加载菜单时,它会抱怨:
org.springframework.expression.spel.SpelEvaluationException: EL1011E:(pos 15): Method call: Attempted to call method expression(java.lang.String) on null context object
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
| 归档时间: |
|
| 查看次数: |
7895 次 |
| 最近记录: |