Springboot Unable to display HTML file cannot find HTML file if HTML file is displayed

Source: Internet
Author: User

Two cases:

1, if the use of the Thymeleaf template engine, HTML files can be placed in the template folder, if not must not be put in, otherwise cannot find, because HTML is static page, so put this type of file in the static folder.

Join in Pom.xml

  <parent> <groupId>org.springframework.boot</groupId> <artifactid>spring-boot-start er-parent</artifactid> <version>1.5.2.RELEASE</version> </parent> <dependencies&gt        ; <dependency> <groupId>org.springframework.boot</groupId> <artifactid>spring- boot-starter-web</artifactid> </dependency> <dependency> <groupid>org.myb Atis.spring.boot</groupid> <artifactId>mybatis-spring-boot</artifactId> <versio n>1.2.0</version> </dependency> <dependency> <groupid>mysql</groupi d> <artifactId>mysql-connector-java</artifactId> </dependency> <dependenc Y> <groupId>org.springframework.boot</groupId> <artifactid>spring-boot-starter- Data-jpa</artifactid> </dependency> <dependency> <groupid>org.springframework.boot</g roupid> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> &lt ;/dependencies>

In resources\templates\hello.html

<! DOCTYPE html>

Add to Controller

@RequestMapping ("/hello") public    String hellohtml (hashmap<string,object> map) {        map.put ("Hello", " Hello ");        return "/hello";    }

Start, and then enter Localhost:8080/hello

Will jump to the page

Note: You must join the ThymeleAF package, or you will not find

2. If no template engine is used, the HTML file will be placed in the static folder because it belongs to a statically file.


Springboot Unable to display HTML file cannot find HTML file if HTML file is displayed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.