(7) Spring Boot and template engine

First, the  original template engine 

(1) In addition to REST Web services, you can also use Spring MVC to provide dynamic HTML content. Spring MVC supports various template technologies, including Thymeleaf , FreeMarker , Velocity, and JSP. Similarly, many other template engines include their own Spring MVC integration.

  • If possible, you should avoid using JSP. There are several known limitations when using them with embedded servlet containers
  • When one of these template engines is used in the default configuration, the template will be automatically extracted from it src/main/resources/templates.
  • Depending on how you run the application, IntelliJ IDEA sorts the classpath differently. The order of running the application from the IDE's main method will be different from when using Maven or Gradle or running the application from the packaged jar. This may prevent Spring Boot from finding templates on the classpath. If you encounter this problem, you can reorder the class path in the IDE to place the module classes and resources first. Alternatively, you can configure the template prefix to search templatesevery directory on the classpath as follows:classpath*:

Guess you like

Origin blog.csdn.net/qq_41893274/article/details/104808341