how to resolve this : Exception evaluating SpringEL expression: "#authorization.expression('isAuthenticated()')"?

fetahokey

i'm working on simple project that implement spring security. the issue come when i tried to work with Logout link with Spring and Thymeleaf.

1.pom.xml

    <!--Spring Boot Dependencies  - Security -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

    <!-- Dependencies Spring Security-->
    <dependency>
        <groupId>org.thymeleaf.extras</groupId>
        <artifactId>thymeleaf-extras-springsecurity4</artifactId>
        <version>2.1.2.RELEASE</version>
        <scope>compile</scope>
    </dependency>

navbar.html

<ul class="nav navbar-nav navbar-right">
                <!--<li><a th:href="@{/login}" th:text="#{navbar.login.text}"></a></li>-->
                <li th:if="${#authorization.expression('isAuthenticated()')}">
                    <a th:href="@{/login}" th:text="#{navbar.login.text}"/>
                </li>
                <li th:if="${#authorization.expression('isAuthenticated()')}">
                    <form id="f" th:action="@{/logout}" method="post" role="form" class="navbar-form">
                        <button type="submit" th:text="#{navbar.logout.text}" class="btn btn-primary"/>
                    </form>
                </li>
            </ul>

error scrrenshot: enter image description here

Jesus David

This error happens when the Thymeleaf Extras Spring Security version is not compatible with the Spring Framework version, in its case, the Spring Boot version works with the Spring Framework version 5.x and the Thymeleaf Extras Spring Security version you have is 4.x. You need update the artifactId in your pom.xml and either choose a compatible version or let Spring Boot choose the version for you

<dependency>
    <groupId>org.thymeleaf.extras</groupId>
    <artifactId>thymeleaf-extras-springsecurity5</artifactId>
    <scope>compile</scope>
</dependency>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Exception evaluating SpringEL expression, spring guru course

How to fix "Exception evaluating SpringEL expression" error after submitting a variable Spring/Thymeleaf

Exception evaluating SpringEL with Spring MVC

org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "ServiceAmc.id" (results:30)

"Exception evaluating SpringEL expression" error while trying to iterate List(<Object>) in Thymeleaf Spring Boot

Exception evaluating SpringEL expression: "#dates.format(passation.datepassation, 'dd-MMM-yyyy')"

Thymeleaf: "Exception evaluating OGNL expression" in a simple for loop

erlang: exception error when evaluating an arithmetic expression

How to prevent CATx functions from evaluating expression

How to Distribute a math expression without evaluating it

How to make a custom HTML id by evaluating an expression

How to resolve MySQLSyntaxErrorException exception?

How to resolve this exception

How to resolve cors origin exception

How to resolve GETJson duplicity exception?

how to resolve number format Exception?

Evaluating an if expression behaves differently then evaluating a BOOL expression

How to obtain all the variables that need to be defined prior evaluating an expression in R?

How do I store a boolean test/expression without Evaluating it?

Evaluating an expression in gekko

Evaluating Expression Tree

Evaluating call expression

evaluating statement cin==(expression)

Evaluating a mathematical expression in a string

CASE expression in MySQL not evaluating

Evaluating JavaScript expression with a worker

Evaluating an Expression using MVEL

Evaluating Expression in Function call

XPath expression not evaluating