i18n fixes Thymeleaf (#1015)
* How to work with dates in Thymeleaf * Fixes in PR for Thymeleaf * Changes to i18n
This commit is contained in:
parent
3f99cfc1d5
commit
e150b2ff54
|
@ -1,272 +1,262 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>spring-thymeleaf</artifactId>
|
<artifactId>spring-thymeleaf</artifactId>
|
||||||
<version>0.1-SNAPSHOT</version>
|
<version>0.1-SNAPSHOT</version>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
|
<properties>
|
||||||
|
<java-version>1.8</java-version>
|
||||||
|
<!-- spring -->
|
||||||
|
<org.springframework-version>4.3.4.RELEASE</org.springframework-version>
|
||||||
|
<springframework-security.version>4.2.0.RELEASE</springframework-security.version>
|
||||||
|
<javax.servlet-version>3.1.0</javax.servlet-version>
|
||||||
|
<!-- logging -->
|
||||||
|
<org.slf4j.version>1.7.21</org.slf4j.version>
|
||||||
|
<logback.version>1.1.7</logback.version>
|
||||||
|
<!-- thymeleaf -->
|
||||||
|
<org.thymeleaf-version>3.0.3.RELEASE</org.thymeleaf-version>
|
||||||
|
<org.thymeleaf.extras-version>3.0.0.RELEASE</org.thymeleaf.extras-version>
|
||||||
|
<thymeleaf-layout-dialect.version>2.1.2</thymeleaf-layout-dialect.version>
|
||||||
|
<!-- validation -->
|
||||||
|
<javax.validation-version>1.1.0.Final</javax.validation-version>
|
||||||
|
<hibernate-validator.version>5.3.3.Final</hibernate-validator.version>
|
||||||
|
<org.hibernate-version>5.2.5.Final</org.hibernate-version>
|
||||||
|
|
||||||
<dependencies>
|
<junit.version>4.12</junit.version>
|
||||||
<!-- Spring -->
|
<!-- Maven plugins -->
|
||||||
<dependency>
|
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
|
||||||
<groupId>org.springframework</groupId>
|
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||||
<artifactId>spring-context</artifactId>
|
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
||||||
<version>${org.springframework-version}</version>
|
<cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
|
||||||
<exclusions>
|
<tomcat7-maven-plugin.version>2.2</tomcat7-maven-plugin.version>
|
||||||
<!-- Exclude Commons Logging in favor of SLF4j -->
|
</properties>
|
||||||
<exclusion>
|
|
||||||
<groupId>commons-logging</groupId>
|
|
||||||
<artifactId>commons-logging</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-webmvc</artifactId>
|
|
||||||
<version>${org.springframework-version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Spring Security -->
|
<dependencies>
|
||||||
<dependency>
|
<!-- Spring -->
|
||||||
<groupId>org.springframework.security</groupId>
|
<dependency>
|
||||||
<artifactId>spring-security-web</artifactId>
|
<groupId>org.springframework</groupId>
|
||||||
<version>${springframework-security.version}</version>
|
<artifactId>spring-context</artifactId>
|
||||||
</dependency>
|
<version>${org.springframework-version}</version>
|
||||||
<dependency>
|
<exclusions>
|
||||||
<groupId>org.springframework.security</groupId>
|
<!-- Exclude Commons Logging in favor of SLF4j -->
|
||||||
<artifactId>spring-security-config</artifactId>
|
<exclusion>
|
||||||
<version>${springframework-security.version}</version>
|
<groupId>commons-logging</groupId>
|
||||||
</dependency>
|
<artifactId>commons-logging</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-webmvc</artifactId>
|
||||||
|
<version>${org.springframework-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- Spring Security -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.security</groupId>
|
||||||
|
<artifactId>spring-security-web</artifactId>
|
||||||
|
<version>${springframework-security.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.security</groupId>
|
||||||
|
<artifactId>spring-security-config</artifactId>
|
||||||
|
<version>${springframework-security.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- Thymeleaf -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.thymeleaf</groupId>
|
||||||
|
<artifactId>thymeleaf</artifactId>
|
||||||
|
<version>${org.thymeleaf-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.thymeleaf</groupId>
|
||||||
|
<artifactId>thymeleaf-spring4</artifactId>
|
||||||
|
<version>${org.thymeleaf-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/nz.net.ultraq.thymeleaf/thymeleaf-layout-dialect -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>nz.net.ultraq.thymeleaf</groupId>
|
||||||
|
<artifactId>thymeleaf-layout-dialect</artifactId>
|
||||||
|
<version>${thymeleaf-layout-dialect.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.thymeleaf.extras</groupId>
|
||||||
|
<artifactId>thymeleaf-extras-java8time</artifactId>
|
||||||
|
<version>${org.thymeleaf.extras-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- Logging -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
<version>${org.slf4j.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
<artifactId>logback-classic</artifactId>
|
||||||
|
<version>${logback.version}</version>
|
||||||
|
<!-- <scope>runtime</scope> -->
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>jcl-over-slf4j</artifactId>
|
||||||
|
<version>${org.slf4j.version}</version>
|
||||||
|
<!-- <scope>runtime</scope> --> <!-- some spring dependencies need to compile against jcl -->
|
||||||
|
</dependency>
|
||||||
|
<dependency> <!-- needed to bridge to slf4j for projects that use the log4j APIs directly -->
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>log4j-over-slf4j</artifactId>
|
||||||
|
<version>${org.slf4j.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- Servlet -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
|
<version>${javax.servlet-version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Validation -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.validation</groupId>
|
||||||
|
<artifactId>validation-api</artifactId>
|
||||||
|
<version>${javax.validation-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hibernate</groupId>
|
||||||
|
<artifactId>hibernate-validator</artifactId>
|
||||||
|
<version>${hibernate-validator.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- test scoped -->
|
||||||
|
|
||||||
<!-- Thymeleaf -->
|
<dependency>
|
||||||
<dependency>
|
<groupId>org.springframework</groupId>
|
||||||
<groupId>org.thymeleaf</groupId>
|
<artifactId>spring-test</artifactId>
|
||||||
<artifactId>thymeleaf</artifactId>
|
<version>${org.springframework-version}</version>
|
||||||
<version>${org.thymeleaf-version}</version>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.thymeleaf</groupId>
|
|
||||||
<artifactId>thymeleaf-spring4</artifactId>
|
|
||||||
<version>${org.thymeleaf-version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-test -->
|
||||||
<groupId>nz.net.ultraq.thymeleaf</groupId>
|
<dependency>
|
||||||
<artifactId>thymeleaf-layout-dialect</artifactId>
|
<groupId>org.springframework.security</groupId>
|
||||||
<version>${thymeleaf-layout-dialect.version}</version>
|
<artifactId>spring-security-test</artifactId>
|
||||||
</dependency>
|
<version>${springframework-security.version}</version>
|
||||||
<dependency>
|
<scope>test</scope>
|
||||||
<groupId>org.thymeleaf.extras</groupId>
|
</dependency>
|
||||||
<artifactId>thymeleaf-extras-java8time</artifactId>
|
|
||||||
<version>${org.thymeleaf.extras-version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Logging -->
|
<!-- https://mvnrepository.com/artifact/junit/junit -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>${org.slf4j.version}</version>
|
<version>${junit.version}</version>
|
||||||
</dependency>
|
<scope>test</scope>
|
||||||
<dependency>
|
</dependency>
|
||||||
<groupId>ch.qos.logback</groupId>
|
|
||||||
<artifactId>logback-classic</artifactId>
|
|
||||||
<version>${logback.version}</version>
|
|
||||||
<!-- <scope>runtime</scope> -->
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>jcl-over-slf4j</artifactId>
|
|
||||||
<version>${org.slf4j.version}</version>
|
|
||||||
<!-- <scope>runtime</scope> --> <!-- some spring dependencies need to compile against jcl -->
|
|
||||||
</dependency>
|
|
||||||
<dependency> <!-- needed to bridge to slf4j for projects that use the log4j APIs directly -->
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>log4j-over-slf4j</artifactId>
|
|
||||||
<version>${org.slf4j.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Servlet -->
|
</dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>javax.servlet</groupId>
|
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
|
||||||
<version>${javax.servlet-version}</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Validation -->
|
<build>
|
||||||
<dependency>
|
<plugins>
|
||||||
<groupId>javax.validation</groupId>
|
<plugin>
|
||||||
<artifactId>validation-api</artifactId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<version>${javax.validation-version}</version>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
</dependency>
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
<dependency>
|
<configuration>
|
||||||
<groupId>org.hibernate</groupId>
|
<source>${java-version}</source>
|
||||||
<artifactId>hibernate-validator</artifactId>
|
<target>${java-version}</target>
|
||||||
<version>${hibernate-validator.version}</version>
|
</configuration>
|
||||||
</dependency>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
|
<version>${maven-war-plugin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>${maven-surefire-plugin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>**/*IntegrationTest.java</exclude>
|
||||||
|
<exclude>**/*LiveTest.java</exclude>
|
||||||
|
</excludes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
<!-- test scoped -->
|
<plugin>
|
||||||
<dependency>
|
<groupId>org.codehaus.cargo</groupId>
|
||||||
<groupId>org.springframework</groupId>
|
<artifactId>cargo-maven2-plugin</artifactId>
|
||||||
<artifactId>spring-test</artifactId>
|
<version>${cargo-maven2-plugin.version}</version>
|
||||||
<version>${org.springframework-version}</version>
|
<configuration>
|
||||||
<scope>test</scope>
|
<wait>true</wait>
|
||||||
</dependency>
|
<container>
|
||||||
|
<containerId>jetty8x</containerId>
|
||||||
|
<type>embedded</type>
|
||||||
|
<systemProperties>
|
||||||
|
</systemProperties>
|
||||||
|
</container>
|
||||||
|
<configuration>
|
||||||
|
<properties>
|
||||||
|
<cargo.servlet.port>8082</cargo.servlet.port>
|
||||||
|
</properties>
|
||||||
|
</configuration>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.tomcat.maven</groupId>
|
||||||
|
<artifactId>tomcat7-maven-plugin</artifactId>
|
||||||
|
<version>${tomcat7-maven-plugin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>tomcat-run</id>
|
||||||
|
<goals>
|
||||||
|
<goal>exec-war-only</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>package</phase>
|
||||||
|
<configuration>
|
||||||
|
<path>/</path>
|
||||||
|
<enableNaming>false</enableNaming>
|
||||||
|
<finalName>webapp.jar</finalName>
|
||||||
|
<charset>utf-8</charset>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
<dependency>
|
<profiles>
|
||||||
<groupId>org.springframework.security</groupId>
|
<profile>
|
||||||
<artifactId>spring-security-test</artifactId>
|
<id>integration</id>
|
||||||
<version>${springframework-security.version}</version>
|
<build>
|
||||||
<scope>test</scope>
|
<plugins>
|
||||||
</dependency>
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<dependency>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<groupId>junit</groupId>
|
<executions>
|
||||||
<artifactId>junit</artifactId>
|
<execution>
|
||||||
<version>${junit.version}</version>
|
<phase>integration-test</phase>
|
||||||
<scope>test</scope>
|
<goals>
|
||||||
</dependency>
|
<goal>test</goal>
|
||||||
|
</goals>
|
||||||
</dependencies>
|
<configuration>
|
||||||
|
<excludes>
|
||||||
<build>
|
<exclude>**/*LiveTest.java</exclude>
|
||||||
<plugins>
|
</excludes>
|
||||||
<plugin>
|
<includes>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<include>**/*IntegrationTest.java</include>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
</includes>
|
||||||
<version>${maven-compiler-plugin.version}</version>
|
</configuration>
|
||||||
<configuration>
|
</execution>
|
||||||
<source>${java-version}</source>
|
</executions>
|
||||||
<target>${java-version}</target>
|
<configuration>
|
||||||
</configuration>
|
<systemPropertyVariables>
|
||||||
</plugin>
|
<test.mime>json</test.mime>
|
||||||
<plugin>
|
</systemPropertyVariables>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
</configuration>
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
</plugin>
|
||||||
<version>${maven-war-plugin.version}</version>
|
</plugins>
|
||||||
<configuration>
|
</build>
|
||||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
</profile>
|
||||||
</configuration>
|
</profiles>
|
||||||
</plugin>
|
</project>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<version>${maven-surefire-plugin.version}</version>
|
|
||||||
<configuration>
|
|
||||||
<excludes>
|
|
||||||
<exclude>**/*IntegrationTest.java</exclude>
|
|
||||||
<exclude>**/*LiveTest.java</exclude>
|
|
||||||
</excludes>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.codehaus.cargo</groupId>
|
|
||||||
<artifactId>cargo-maven2-plugin</artifactId>
|
|
||||||
<version>${cargo-maven2-plugin.version}</version>
|
|
||||||
<configuration>
|
|
||||||
<wait>true</wait>
|
|
||||||
<container>
|
|
||||||
<containerId>jetty8x</containerId>
|
|
||||||
<type>embedded</type>
|
|
||||||
<systemProperties>
|
|
||||||
</systemProperties>
|
|
||||||
</container>
|
|
||||||
<configuration>
|
|
||||||
<properties>
|
|
||||||
<cargo.servlet.port>8082</cargo.servlet.port>
|
|
||||||
</properties>
|
|
||||||
</configuration>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.tomcat.maven</groupId>
|
|
||||||
<artifactId>tomcat7-maven-plugin</artifactId>
|
|
||||||
<version>${tomcat7-maven-plugin.version}</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>tomcat-run</id>
|
|
||||||
<goals>
|
|
||||||
<goal>exec-war-only</goal>
|
|
||||||
</goals>
|
|
||||||
<phase>package</phase>
|
|
||||||
<configuration>
|
|
||||||
<path>/</path>
|
|
||||||
<enableNaming>false</enableNaming>
|
|
||||||
<finalName>webapp.jar</finalName>
|
|
||||||
<charset>utf-8</charset>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>integration</id>
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>integration-test</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>test</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<excludes>
|
|
||||||
<exclude>**/*LiveTest.java</exclude>
|
|
||||||
</excludes>
|
|
||||||
<includes>
|
|
||||||
<include>**/*IntegrationTest.java</include>
|
|
||||||
</includes>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
|
||||||
<systemPropertyVariables>
|
|
||||||
<test.mime>json</test.mime>
|
|
||||||
</systemPropertyVariables>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<java-version>1.8</java-version>
|
|
||||||
<!-- spring -->
|
|
||||||
<org.springframework-version>4.3.5.RELEASE</org.springframework-version>
|
|
||||||
<springframework-security.version>4.2.1.RELEASE</springframework-security.version>
|
|
||||||
<javax.servlet-version>3.1.0</javax.servlet-version>
|
|
||||||
|
|
||||||
<!-- logging -->
|
|
||||||
<org.slf4j.version>1.7.21</org.slf4j.version>
|
|
||||||
<logback.version>1.1.7</logback.version>
|
|
||||||
|
|
||||||
<!-- thymeleaf -->
|
|
||||||
<org.thymeleaf-version>3.0.3.RELEASE</org.thymeleaf-version>
|
|
||||||
<org.thymeleaf.extras-version>3.0.0.RELEASE</org.thymeleaf.extras-version>
|
|
||||||
<thymeleaf-layout-dialect.version>2.1.2</thymeleaf-layout-dialect.version>
|
|
||||||
|
|
||||||
<!-- validation -->
|
|
||||||
<javax.validation-version>1.1.0.Final</javax.validation-version>
|
|
||||||
<hibernate-validator.version>5.3.3.Final</hibernate-validator.version>
|
|
||||||
<org.hibernate-version>5.2.5.Final</org.hibernate-version>
|
|
||||||
|
|
||||||
<junit.version>4.12</junit.version>
|
|
||||||
|
|
||||||
<!-- Maven plugins -->
|
|
||||||
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
|
|
||||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
|
||||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
|
||||||
<cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
|
|
||||||
<tomcat7-maven-plugin.version>2.2</tomcat7-maven-plugin.version>
|
|
||||||
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
</project>
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.baeldung.thymeleaf.config;
|
package com.baeldung.thymeleaf.config;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationContextAware;
|
import org.springframework.context.ApplicationContextAware;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
@ -8,10 +10,14 @@ import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Description;
|
import org.springframework.context.annotation.Description;
|
||||||
import org.springframework.context.support.ResourceBundleMessageSource;
|
import org.springframework.context.support.ResourceBundleMessageSource;
|
||||||
import org.springframework.format.FormatterRegistry;
|
import org.springframework.format.FormatterRegistry;
|
||||||
|
import org.springframework.web.servlet.LocaleResolver;
|
||||||
import org.springframework.web.servlet.ViewResolver;
|
import org.springframework.web.servlet.ViewResolver;
|
||||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||||
|
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
|
||||||
|
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
|
||||||
import org.thymeleaf.TemplateEngine;
|
import org.thymeleaf.TemplateEngine;
|
||||||
import org.thymeleaf.extras.java8time.dialect.Java8TimeDialect;
|
import org.thymeleaf.extras.java8time.dialect.Java8TimeDialect;
|
||||||
import org.thymeleaf.spring4.SpringTemplateEngine;
|
import org.thymeleaf.spring4.SpringTemplateEngine;
|
||||||
|
@ -41,70 +47,70 @@ public class WebMVCConfig extends WebMvcConfigurerAdapter implements Application
|
||||||
this.applicationContext = applicationContext;
|
this.applicationContext = applicationContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ViewResolver htmlViewResolver() {
|
public ViewResolver htmlViewResolver() {
|
||||||
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
|
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
|
||||||
resolver.setTemplateEngine(templateEngine(htmlTemplateResolver()));
|
resolver.setTemplateEngine(templateEngine(htmlTemplateResolver()));
|
||||||
resolver.setContentType("text/html");
|
resolver.setContentType("text/html");
|
||||||
resolver.setCharacterEncoding("UTF-8");
|
resolver.setCharacterEncoding("UTF-8");
|
||||||
resolver.setViewNames(ArrayUtil.array("*.html"));
|
resolver.setViewNames(ArrayUtil.array("*.html"));
|
||||||
return resolver;
|
return resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ViewResolver javascriptViewResolver() {
|
public ViewResolver javascriptViewResolver() {
|
||||||
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
|
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
|
||||||
resolver.setTemplateEngine(templateEngine(javascriptTemplateResolver()));
|
resolver.setTemplateEngine(templateEngine(javascriptTemplateResolver()));
|
||||||
resolver.setContentType("application/javascript");
|
resolver.setContentType("application/javascript");
|
||||||
resolver.setCharacterEncoding("UTF-8");
|
resolver.setCharacterEncoding("UTF-8");
|
||||||
resolver.setViewNames(ArrayUtil.array("*.js"));
|
resolver.setViewNames(ArrayUtil.array("*.js"));
|
||||||
return resolver;
|
return resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ViewResolver plainViewResolver() {
|
public ViewResolver plainViewResolver() {
|
||||||
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
|
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
|
||||||
resolver.setTemplateEngine(templateEngine(plainTemplateResolver()));
|
resolver.setTemplateEngine(templateEngine(plainTemplateResolver()));
|
||||||
resolver.setContentType("text/plain");
|
resolver.setContentType("text/plain");
|
||||||
resolver.setCharacterEncoding("UTF-8");
|
resolver.setCharacterEncoding("UTF-8");
|
||||||
resolver.setViewNames(ArrayUtil.array("*.txt"));
|
resolver.setViewNames(ArrayUtil.array("*.txt"));
|
||||||
return resolver;
|
return resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TemplateEngine templateEngine(ITemplateResolver templateResolver) {
|
private TemplateEngine templateEngine(ITemplateResolver templateResolver) {
|
||||||
SpringTemplateEngine engine = new SpringTemplateEngine();
|
SpringTemplateEngine engine = new SpringTemplateEngine();
|
||||||
engine.addDialect(new LayoutDialect(new GroupingStrategy()));
|
engine.addDialect(new LayoutDialect(new GroupingStrategy()));
|
||||||
engine.addDialect(new Java8TimeDialect());
|
engine.addDialect(new Java8TimeDialect());
|
||||||
engine.setTemplateResolver(templateResolver);
|
engine.setTemplateResolver(templateResolver);
|
||||||
return engine;
|
return engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ITemplateResolver htmlTemplateResolver() {
|
private ITemplateResolver htmlTemplateResolver() {
|
||||||
SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
|
SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
|
||||||
resolver.setApplicationContext(applicationContext);
|
resolver.setApplicationContext(applicationContext);
|
||||||
resolver.setPrefix("/WEB-INF/views/");
|
resolver.setPrefix("/WEB-INF/views/");
|
||||||
resolver.setCacheable(false);
|
resolver.setCacheable(false);
|
||||||
resolver.setTemplateMode(TemplateMode.HTML);
|
resolver.setTemplateMode(TemplateMode.HTML);
|
||||||
return resolver;
|
return resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ITemplateResolver javascriptTemplateResolver() {
|
private ITemplateResolver javascriptTemplateResolver() {
|
||||||
SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
|
SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
|
||||||
resolver.setApplicationContext(applicationContext);
|
resolver.setApplicationContext(applicationContext);
|
||||||
resolver.setPrefix("/WEB-INF/js/");
|
resolver.setPrefix("/WEB-INF/js/");
|
||||||
resolver.setCacheable(false);
|
resolver.setCacheable(false);
|
||||||
resolver.setTemplateMode(TemplateMode.JAVASCRIPT);
|
resolver.setTemplateMode(TemplateMode.JAVASCRIPT);
|
||||||
return resolver;
|
return resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ITemplateResolver plainTemplateResolver() {
|
private ITemplateResolver plainTemplateResolver() {
|
||||||
SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
|
SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
|
||||||
resolver.setApplicationContext(applicationContext);
|
resolver.setApplicationContext(applicationContext);
|
||||||
resolver.setPrefix("/WEB-INF/txt/");
|
resolver.setPrefix("/WEB-INF/txt/");
|
||||||
resolver.setCacheable(false);
|
resolver.setCacheable(false);
|
||||||
resolver.setTemplateMode(TemplateMode.TEXT);
|
resolver.setTemplateMode(TemplateMode.TEXT);
|
||||||
return resolver;
|
return resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Description("Spring Message Resolver")
|
@Description("Spring Message Resolver")
|
||||||
|
@ -114,12 +120,31 @@ public class WebMVCConfig extends WebMvcConfigurerAdapter implements Application
|
||||||
return messageSource;
|
return messageSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Bean
|
||||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
public LocaleResolver localeResolver() {
|
||||||
registry.addResourceHandler("/resources/**").addResourceLocations("/WEB-INF/resources/");
|
SessionLocaleResolver localeResolver = new SessionLocaleResolver();
|
||||||
|
localeResolver.setDefaultLocale(new Locale("en"));
|
||||||
|
return localeResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public LocaleChangeInterceptor localeChangeInterceptor() {
|
||||||
|
LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
|
||||||
|
localeChangeInterceptor.setParamName("lang");
|
||||||
|
return localeChangeInterceptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
registry.addInterceptor(localeChangeInterceptor());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
|
registry.addResourceHandler("/resources/**").addResourceLocations("/WEB-INF/resources/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Description("Custom Conversion Service")
|
@Description("Custom Conversion Service")
|
||||||
public void addFormatters(FormatterRegistry registry) {
|
public void addFormatters(FormatterRegistry registry) {
|
||||||
registry.addFormatter(new NameFormatter());
|
registry.addFormatter(new NameFormatter());
|
||||||
|
|
|
@ -13,13 +13,13 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
@Controller
|
@Controller
|
||||||
public class DatesController {
|
public class DatesController {
|
||||||
|
|
||||||
@RequestMapping(value = "/dates", method = RequestMethod.GET)
|
@RequestMapping(value = "/dates", method = RequestMethod.GET)
|
||||||
public String getInfo(Model model) {
|
public String getInfo(Model model) {
|
||||||
model.addAttribute("standardDate", new Date());
|
model.addAttribute("standardDate", new Date());
|
||||||
model.addAttribute("localDateTime", LocalDateTime.now());
|
model.addAttribute("localDateTime", LocalDateTime.now());
|
||||||
model.addAttribute("localDate", LocalDate.now());
|
model.addAttribute("localDate", LocalDate.now());
|
||||||
model.addAttribute("timestamp", Instant.now());
|
model.addAttribute("timestamp", Instant.now());
|
||||||
return "dates.html";
|
return "dates.html";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ public class HomeController {
|
||||||
|
|
||||||
@RequestMapping(value = "/", method = RequestMethod.GET)
|
@RequestMapping(value = "/", method = RequestMethod.GET)
|
||||||
public String getHome(Model model) {
|
public String getHome(Model model) {
|
||||||
|
|
||||||
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, Locale.getDefault());
|
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, Locale.getDefault());
|
||||||
model.addAttribute("serverTime", dateFormat.format(new Date()));
|
model.addAttribute("serverTime", dateFormat.format(new Date()));
|
||||||
return "home.html";
|
return "home.html";
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
<html xmlns:th="http://www.thymeleaf.org"
|
||||||
xmlns:th="http://www.thymeleaf.org">
|
th:with="lang=${#locale.language}" th:lang="${lang}">
|
||||||
<head>
|
<head>
|
||||||
<title>Home</title>
|
<title>Home</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -31,25 +31,24 @@ import com.baeldung.thymeleaf.config.WebMVCSecurity;
|
||||||
@ContextConfiguration(classes = { WebApp.class, WebMVCConfig.class, WebMVCSecurity.class, InitSecurity.class })
|
@ContextConfiguration(classes = { WebApp.class, WebMVCConfig.class, WebMVCSecurity.class, InitSecurity.class })
|
||||||
public class ExpressionUtilityObjectsControllerIntegrationTest {
|
public class ExpressionUtilityObjectsControllerIntegrationTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
WebApplicationContext wac;
|
WebApplicationContext wac;
|
||||||
|
@Autowired
|
||||||
@Autowired
|
MockHttpSession session;
|
||||||
MockHttpSession session;
|
|
||||||
|
|
||||||
private MockMvc mockMvc;
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private Filter springSecurityFilterChain;
|
private Filter springSecurityFilterChain;
|
||||||
|
|
||||||
protected RequestPostProcessor testUser() {
|
protected RequestPostProcessor testUser() {
|
||||||
return user("user1").password("user1Pass").roles("USER");
|
return user("user1").password("user1Pass").roles("USER");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
mockMvc = MockMvcBuilders.webAppContextSetup(wac).addFilters(springSecurityFilterChain).build();
|
mockMvc = MockMvcBuilders.webAppContextSetup(wac).addFilters(springSecurityFilterChain).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetObjects() throws Exception {
|
public void testGetObjects() throws Exception {
|
||||||
|
|
Loading…
Reference in New Issue