Home > Software design >  How can i connect my page with Controller
How can i connect my page with Controller

Time:03-29

Here i am trying to make a new page with EventController and connect with thymeleaf

@Controller
public class EventController {
 @RequestMapping(value = "/pereschet", method = RequestMethod.GET)
    public String welcome() {
        return "boom";
    }
}

here is my html page boom.html

<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
      xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
      layout:decorator="layout">
<head>
    <title>Index</title>
</head>
<body>
<h1 >Boombom</h1>


</body>
</html>

it is giving me error not found when i am reaching the /timetracking/compensatory/boom error is Error resolving template "boom", template might not exist or might not be accessible by any of the configured Template Resolvers

I want to expect the working page, what are the ideas?

CodePudding user response:

The default template directory for thymeleaf is src/main/resources/templates. Please make sure you have boom.html placed in this directory as there is no template resolver as per your question. Please take a look at this link I found online for details on custom template resolver. Spring Boot with Thymeleaf

  • Related