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

Time:2020-9-23

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

@GetMapping("/")
   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

net.sourceforge.nekohtml 
nekohtml 
1.9.22

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

src/main/resources

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:

Recommended Today

Layout of angular material (2): layout container

Layout container Layout and container Using thelayoutDirective to specify the layout direction for its child elements: arrange horizontally(layout=”row”)Or vertically(layout=”column”)。 Note that if thelayoutInstruction has no value, thenrowIs the default layout direction. row: items arranged horizontally.max-height = 100%andmax-widthIs the width of the item in the container. column: items arranged vertically.max-width = 100%andmax-heightIs the height of the […]