Springboot direct access html


When Springboot direct access html
application.properties add the following configuration:
Catalog # positioning template
spring.mvc.view.prefix = the CLASSPATH: / Templates /
# to return the page to add the suffix
spring.mvc.view.suffix = .html
Back to controller:
@GetMapping ( "/ index")
 public String index () {
   return "Home"; // when the browser input / index, the page will return /templates/home.html
}
Note:
the Spring the Boot is enabled by default static configuration files, any folder on static resources are static files. When referring to a static file with / or without any prefix locators will go static folder to find.
Under Thymeleaf default template will be used as the view file templatess

Guess you like

Origin www.cnblogs.com/cmz-32000/p/11588929.html