Spring Boot integration Thymeleaf case of pit layout

 SpringBoot Embedded Servlet container, the default template parsing does not support JSP, it requires additional configuration is basically the beginning will will choose SpringBoot recommended Thymeleaf template engine to render the view;

In just a Thymeleaf, but feel okay, JSP with the fact that far, but their actual operate time, or encountered a pit, the pit is long Thymeleaf page layout path is the path under the templates based on, instead of a relative path;

 

In case of pit process:

In templates, my project path is as follows: 

 --templates

  --crud(d)

    --emp(d)

    --commons(d)

      --module.html(f)

    --list.html(f)

    --add.html(f)

 

module.html inside my template files:

 

 Then in list.html under emp file folder module.html introduced commons Public fragment ( TMD also suggest that it is the correct Rapture ):

 

 The results of a project started visit, the background has been 500 reported the following error:

org.thymeleaf.exceptions.TemplateInputException: Error resolving template [crud/emp/list], template might not exist or might not be accessible by any of the configured Template Resolvers
    at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869) ~[thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]
    at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607) ~[thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]

 

 Internet search several ways to resolve this situation:

  1. What is the use of @ RestController, @ ResponseBody (do not mistake this range)

  2. Thymeleaf requires HTML5 specification, can not appear single label (label meal solve a single operation, or not, the result would have thymeleaf3.0 not demanding the html5)

  3. be introduced thymeleaf-layout-dialect dependency (used or not added)

  4. It was suggested that clearance maven repository (no way, the local maven repository deleted, re-pull dependencies, the result was not)

 

Very Ben collapse, want to have a powerful master, but wood. . .

Finally, the test accidentally found the original layout of the segment path to be introduced to tempaltes path is okay, then the entire folder commons to the directories of templates ( but not in the segment layout incorporated list.hmlt before there is a path prompted to write )

 

 I did not expect it, and did not suggest that the results can be accessed, tears Yeah, but finally resolved. . .

 

Guess you like

Origin www.cnblogs.com/gangbalei/p/11499143.html