diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml
index 38cbfddab8..2180b917e5 100644
--- a/spring-security-rest-custom/pom.xml
+++ b/spring-security-rest-custom/pom.xml
@@ -26,6 +26,14 @@
org.springframework.security
spring-security-config
+
+ org.thymeleaf.extras
+ thymeleaf-extras-springsecurity5
+
+
+ org.thymeleaf
+ thymeleaf-spring5
+
diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/config/child/WebConfig.java b/spring-security-rest-custom/src/main/java/org/baeldung/config/child/WebConfig.java
index 6688d41ffa..7cbbcf31fa 100644
--- a/spring-security-rest-custom/src/main/java/org/baeldung/config/child/WebConfig.java
+++ b/spring-security-rest-custom/src/main/java/org/baeldung/config/child/WebConfig.java
@@ -2,19 +2,34 @@ package org.baeldung.config.child;
import java.util.List;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+import org.thymeleaf.extras.springsecurity5.dialect.SpringSecurityDialect;
+import org.thymeleaf.spring5.ISpringTemplateEngine;
+import org.thymeleaf.spring5.SpringTemplateEngine;
+import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver;
+import org.thymeleaf.spring5.view.ThymeleafViewResolver;
+import org.thymeleaf.templatemode.TemplateMode;
+import org.thymeleaf.templateresolver.ITemplateResolver;
@Configuration
@EnableWebMvc
@ComponentScan("org.baeldung.web")
+//@ImportResource({ "classpath:prop.xml" })
+//@PropertySource("classpath:foo.properties")
public class WebConfig implements WebMvcConfigurer {
+
+ @Autowired
+ private ApplicationContext applicationContext;
public WebConfig() {
super();
@@ -35,5 +50,31 @@ public class WebConfig implements WebMvcConfigurer {
ppc.setIgnoreUnresolvablePlaceholders(true);
return ppc;
}
+
+ @Bean
+ public ViewResolver viewResolver() {
+ ThymeleafViewResolver resolver = new ThymeleafViewResolver();
+ resolver.setTemplateEngine(templateEngine());
+ resolver.setCharacterEncoding("UTF-8");
+ return resolver;
+ }
+
+ @Bean
+ public ISpringTemplateEngine templateEngine() {
+ SpringTemplateEngine engine = new SpringTemplateEngine();
+ engine.setEnableSpringELCompiler(true);
+ engine.setTemplateResolver(templateResolver());
+ engine.addDialect(new SpringSecurityDialect());
+ return engine;
+ }
+
+ private ITemplateResolver templateResolver() {
+ SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
+ resolver.setApplicationContext(applicationContext);
+ resolver.setPrefix("/WEB-INF/templates/");
+ resolver.setSuffix(".html");
+ resolver.setTemplateMode(TemplateMode.HTML);
+ return resolver;
+ }
}
\ No newline at end of file
diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/config/parent/SecurityConfig.java b/spring-security-rest-custom/src/main/java/org/baeldung/config/parent/SecurityConfig.java
index 74e2df2174..fb3880a33f 100644
--- a/spring-security-rest-custom/src/main/java/org/baeldung/config/parent/SecurityConfig.java
+++ b/spring-security-rest-custom/src/main/java/org/baeldung/config/parent/SecurityConfig.java
@@ -10,6 +10,7 @@ import org.springframework.security.config.annotation.web.configuration.EnableWe
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@Configuration
+//@ImportResource({ "classpath:webSecurityConfig.xml" })
@EnableWebSecurity
@ComponentScan("org.baeldung.security")
public class SecurityConfig extends WebSecurityConfigurerAdapter {
diff --git a/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/ViewController.java b/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/ViewController.java
new file mode 100644
index 0000000000..83c0292d98
--- /dev/null
+++ b/spring-security-rest-custom/src/main/java/org/baeldung/web/controller/ViewController.java
@@ -0,0 +1,13 @@
+package org.baeldung.web.controller;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+@Controller
+public class ViewController {
+
+ @RequestMapping({ "/index", "/" })
+ public String index() {
+ return "index";
+ }
+}
diff --git a/spring-security-rest-custom/src/main/resources/prop.xml b/spring-security-rest-custom/src/main/resources/prop.xml
new file mode 100644
index 0000000000..edaecde655
--- /dev/null
+++ b/spring-security-rest-custom/src/main/resources/prop.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-security-rest-custom/src/main/resources/webSecurityConfig.xml b/spring-security-rest-custom/src/main/resources/webSecurityConfig.xml
index fa5dc894bf..790b1b1716 100644
--- a/spring-security-rest-custom/src/main/resources/webSecurityConfig.xml
+++ b/spring-security-rest-custom/src/main/resources/webSecurityConfig.xml
@@ -2,9 +2,9 @@
diff --git a/spring-security-rest-custom/src/main/webapp/WEB-INF/templates/index.html b/spring-security-rest-custom/src/main/webapp/WEB-INF/templates/index.html
new file mode 100644
index 0000000000..31cb66ae0a
--- /dev/null
+++ b/spring-security-rest-custom/src/main/webapp/WEB-INF/templates/index.html
@@ -0,0 +1,7 @@
+
+
+
+ Authenticated as
+
+
\ No newline at end of file
diff --git a/spring-security-rest-custom/src/main/webapp/WEB-INF/web_old.xml b/spring-security-rest-custom/src/main/webapp/WEB-INF/web_old.xml
new file mode 100644
index 0000000000..0fa9abd258
--- /dev/null
+++ b/spring-security-rest-custom/src/main/webapp/WEB-INF/web_old.xml
@@ -0,0 +1,51 @@
+
+
+
+ Spring Security Custom Application
+
+
+
+ contextClass
+
+ org.springframework.web.context.support.AnnotationConfigWebApplicationContext
+
+
+
+ contextConfigLocation
+ org.baeldung.config.parent
+
+
+
+ org.springframework.web.context.ContextLoaderListener
+
+
+
+
+ api
+ org.springframework.web.servlet.DispatcherServlet
+
+
+
+
+ 1
+
+
+ api
+ /api/*
+
+
+
+
+ springSecurityFilterChain
+ org.springframework.web.filter.DelegatingFilterProxy
+
+
+ springSecurityFilterChain
+ /*
+
+
+
\ No newline at end of file