When I write some controllers in Spring Boot project, I want to use the annotation @ResponseBody to test if the controller interface works normally, so I created a controller like this:
@ResponseBody
@GetMapping("/about")
public ModelAndView about(){
return new ModelAndView("about");
}
To test if this controller was working, I used the browser to test it. I didn't use the URL about.html, so I expected the browser should have shown a JSON string to describe the ModelAndView object. This isn't what happened; instead it showed an error that the dispatchServlet cannot resolve the template.
It seems like the annotation is not working. I cleared my cache, cleaned the project, and rebuilt it, but that didn't help. What am I doing wrong?