Ich verwende Sicherheit in meiner Spring-App.Versuch, den Methodenausdruck (java.lang.String) für das Nullkontextobjekt aufzurufen
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
und hier ist mein Controller für die Anmeldung:
@Configuration
static class ClientWebConfig extends WebMvcConfigurerAdapter {
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/login").setViewName("fragments/login");
}
}
dann habe ich gemacht Menü und dort habe ich versucht, Logout-Button zu machen:
<li th:if="${#authorization.expression('isAuthenticated()')}">
<a href="/logout" th:href="@{/logout}">Logout</a>
</li>
Ich kann login correctly
, aber wenn es lädt das Menü, mit dem es sich beschwert:
org.springframework.expression.spel.SpelEvaluationException: EL1011E:(pos 15): Method call: Attempted to call method expression(java.lang.String) on null context object
Wie kann ich es beheben?
Möchten Sie die thymeleaf Erweiterungen für Spring Security in Ihrer Abhängigkeitsliste haben? –