Spring - class path Resource cannot be opened because it does not exist

Asked

Viewed 226 times

0

I’m trying to upload a simple HTML page on Tomcat with spring and Thymeleaf, but when access gives the error:

An error happened During template Parsing (template: "class path Resource .. templates/beer/Registration.html... and also class path Resource [templates/beer/Register.html] cannot be opened because it does not exist

my structure looks like this: src/main/java/webconfig.java

    private ITemplateResolver templateResolver() { // class que dita onde fica o template
        SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
        resolver.setApplicationContext(applicationContext);
        resolver.setPrefix("classpath:/templates/");
        resolver.setSuffix(".html");
        resolver.setTemplateMode(TemplateMode.HTML);
        return resolver;
    }


src/main/java/controller

    @Controller
public class CervejasController {

    @RequestMapping("/cervejas/novo") //Mapeia a URL
    public String novo() {
        return "cerveja/CadastroCerveja";
    }
}

and the HTML I’m tetando calling is in:

SRC/MAIN/RESOURCE/TEMPLATES/CERVEJA/CadastroCerveja.HTML

  • Can you post your html page? And if you’re using Maven, you can post your pom.xml?

  • The address of the TEMPLATES folder is all uppercase and templateResolver is lowercase. This could be it.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.