Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can i set prefix path for thymeleaf in spring boot

Tags:

spring-boot

How can I set the prefix path(set the new directory) to render the HTML page?

I have a spring boot application. I am using version 2.1.7.

  • I am set a new path for view page.
like image 980
Deepanker Sharma Avatar asked Sep 05 '19 06:09

Deepanker Sharma


People also ask

Where do Thymeleaf templates go in spring-boot?

Thymeleaf in Spring Boot By default, HTML files should be placed in the resources/templates location.

How do I get the URL parameter in Thymeleaf?

Another way of accessing request parameters in thymeleaf is by using #httpServletRequest utility object which gives direct access to javax. servlet. http. HttpServletRequest object.


2 Answers

Add the following line in Application.properties

spring.thymeleaf.check-template-location=true
spring.thymeleaf.prefix=classpath:/templates/views/    #this is the main
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.servlet.content-type=text/html
spring.thymeleaf.cache=false
spring.main.allow-bean-definition-overriding=true
like image 128
Pradeep Maurya Avatar answered Oct 27 '22 01:10

Pradeep Maurya


You can use basic setup or by overriding a property in application.properties to give your own customise page.

A prefix that gets prepended to view names when building a URL.

spring.thymeleaf.prefix=classpath:/config/templates/
like image 30
vikash Avatar answered Oct 27 '22 01:10

vikash