ropo
ropo

Reputation: 1496

Spring boot @GetMapping for root not working

My Spring Boot controller is working just fine, except that I cannot create a mapping for the home directory. I have tried:

@Controller
public class MyController {
   @GetMapping(value = {"/"})
   public ModelAndView searchPage(Locale locale) {
     ModelAndView model = new ModelAndView();
     model.setViewName("pageTemplate");
     return model;
   }
}

  @GetMapping(value = "/")
  @GetMapping(value = "")
  @GetMapping
  @RequestMapping with all values above

I always get my 404 error page. If this is supposed to work, how can I debug why it is not?

Upvotes: 2

Views: 3283

Answers (1)

ropo
ropo

Reputation: 1496

Found it. I set in application.properties: logging.level.org.springframework.web: DEBUG which then displayed

 o.s.w.s.mvc.ServletForwardingController  : Forwarded to servlet [springVaadinServlet] in ServletForwardingController 'vaadinUiForwardingController'

It turns out that I have used @SpringUI without specifying a path

Upvotes: 2

Related Questions