This is my Controller class
@Controller
public class PageController {
@GetMapping(value="/")
public String homePage() {
return "index";
}
}
And I also have a RestController class
@RestController
public class MyRestController {
@Autowired
private AddPostService addPostService;
@PostMapping("/addpost")
public boolean processBlogPost(@RequestBody BlogPost blogPost)
{
blogPost.setCreatedDate(new java.util.Date());
addPostService.insertBlogPost(blogPost);
return true;
}
}
I have included all the necessary packages in the @ComponentScan
of the Spring Application class.
I tried placing the index.html
page in both src/main/resources/static
and src/main/resources/templates
. But when I load localhost:8080
it shows Whitelabel error page
.
While debugging, the control is actually reaching return "index";
, but the page is not displayed.