【发布时间】:2016-09-21 10:25:16
【问题描述】:
我在我的 spring 应用程序中使用安全性。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
这是我的登录控制器:
@Configuration
static class ClientWebConfig extends WebMvcConfigurerAdapter {
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/login").setViewName("fragments/login");
}
}
然后我制作了菜单并尝试制作注销按钮:
<li th:if="${#authorization.expression('isAuthenticated()')}">
<a href="/logout" th:href="@{/logout}">Logout</a>
</li>
我可以正确登录,但是当它加载菜单时它会抱怨:
org.springframework.expression.spel.SpelEvaluationException: EL1011E:(pos 15): Method call: Attempted to call method expression(java.lang.String) on null context object
我该如何解决?
【问题讨论】:
-
你的依赖列表中有 Spring Security 的 thymeleaf 扩展吗?