fuzzy28 February 2016

Undefined attribute name (sec:authentication)

I'm using Thymleaf in my spring security simple POC. Below is my sample code in home.html file.

Hello <span sec:authentication="name">User</span>!i

How to get rid of the html warning

Undefined attribute name (sec:authentication).

Answers


romach February 2016

1) Add this dependency to pom.xml:

<dependency>
    <groupId>org.thymeleaf.extras</groupId>
    <artifactId>thymeleaf-extras-springsecurity3</artifactId>
    <version>3.0.0.BETA01</version>
</dependency>

2) Add additional dialect to templateEngine bean:

<!-- Thymeleaf Template Engine (Spring4-specific version) -->
<bean id="templateEngine" class="org.thymeleaf.spring4.SpringTemplateEngine">
    <property name="templateResolvers">
        <set>
            <ref bean="templateResolver" />
        </set>
    </property>
    <property name="additionalDialects">
        <set>
             <bean class="org.thymeleaf.extras.springsecurity3.dialect.SpringSecurityDialect" />
        </set>
    </property>
</bean>


fuzzy28 February 2016

I Just duplicate the namespace for sec tag and html warning disappear

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:th="http://www.thymeleaf.org"
    xmlns:sec="http://www.thymeleaf.org">

Post Status

Asked in February 2016
Viewed 3,105 times
Voted 8
Answered 2 times

Search




Leave an answer