angularjs - Spring boot - Thymeleaf template - multiple resolvers -


we have multiple thmeleaf template resolvers in our project.

our project structure,

/src/main/java/*.java /src/main/resources/pages/*.html /src/main/resources/templates/*.html 

inside, resources, have pages , templates folder.

so, have add 1 more view resolvers have html files inside pages.

@configuration public class thymeleafconfig {      @autowired     private springtemplateengine templateengine;      @postconstruct     public void init() {         classloadertemplateresolver resolver = new classloadertemplateresolver();          resolver.setprefix("pages/");         resolver.setsuffix(".html");         resolver.settemplatemode("legacyhtml5");         resolver.setorder(templateengine.gettemplateresolvers().size());          templateengine.addtemplateresolver(resolver);     }  } 

now, move few files /srs/main/webapp/

/src/main/resources/ /src/main/webapp/*.html 

so, tried above config file with,

resolver.setprefix("webapp/"); 

tried below code also,

 resolver.setprefix("/webapp/"); 

now, getting following error.

2015-10-27 15:36:13.078 [http-nio-8080-exec-8] error org.thymeleaf.templateengine - [thymeleaf][http-nio-8080-exec-8] exception processing template "agent": error resolving template "agent", template might not exist or might not accessible of configured template resolvers 2015-10-27 15:36:13.094 [http-nio-8080-exec-8] error o.a.c.c.c.[.[.[.[dispatcherservlet] - servlet.service() servlet [dispatcherservlet] in context path [] threw exception [request processing failed; nested exception org.thymeleaf.exceptions.templateinputexception: error resolving template "agent", template might not exist or might not accessible of configured template resolvers] root cause org.thymeleaf.exceptions.templateinputexception: error resolving template "agent", template might not exist or might not accessible of configured template resolvers     @ org.thymeleaf.templaterepository.gettemplate(templaterepository.java:246) ~[thymeleaf-2.1.4.release.jar:2.1.4.release]     @ org.thymeleaf.templateengine.process(templateengine.java:1104) ~[thymeleaf-2.1.4.release.jar:2.1.4.release] 

any other configuration done webapp folder ...

changing classloadertemplateresolver servletcontexttemplateresolver solved problem. guess, duo security reasons, classloadertemplateresolver unable read file under webapp.

@postconstruct     public void init() {         servletcontexttemplateresolver resolver = new servletcontexttemplateresolver();          resolver.setprefix("/");         resolver.setsuffix(".html");         resolver.settemplatemode("legacyhtml5");         resolver.setorder(templateengine.gettemplateresolvers().size());          templateengine.addtemplateresolver(resolver);     } 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -