org.thymeleaf.exceptions . templateinputexception: error resolving template reported an error


The error that appears is what the title says: org.thymeleaf.exceptions . templateinputexception: error resolving template reports an error, which is the following code

   public String index() {
       return "index";

At the beginning of this error, I immediately Baidu, and then see the following several solutions

1. When the controller layer returns after processing the request, it does not use @ restcontroller or @ ResponseBody, but returns non JSON format

I used this method to solve the problem. No error was reported. However, the jump page was displayed with the character index, and there was no page skipping at all. So I checked this question again. Someone from other blogs answered that @ restcontroller returns a string type to the page instead of a JSON type. You must change @ restcontroller back to @ control, and then change it back and report an error… At the beginning of the real despair, dead circle!!! Then the following methods are useless to me, but may be useful to you, I also share with you!

2. When the corresponding method of your controller layer returns the HTML path and name, add an additional one before it/

For example: return “/ index”. If the / causes an error, the solution is to remove the / in front of it, such as return “/ index”

3. In the process of using springboot, if thymeleaf is used as template file, the HTML format must be strict HTML5 format, and there must be an end tag. Otherwise, an error will be reported

The solutions are as follows:
stay application.yml Add the following configuration to

spring.thymeleaf.content-type: text/html 
spring.thymeleaf.cache: false 
spring.thymeleaf.mode: LEGACYHTML5

Again pom.xml Add the following dependencies


4. The path of the resource file has been modified. If your other requests return normally, you can ignore this one
Solution: in pom.xml In the document


The above three methods don’t work for me

In fact, my problem seems to be because of the cache problem. It took two hours at that time, and then the idea was restarted. The result is inexplicable. So if you encounter this situation and the above methods are useless, you might as well restart the idea and clear the cache! Cache clearing place: