'Unable to fetch the view file

On making a GET Request which returns a ModelAndView Object I am getting the following error

: GET "/[email protected]", parameters={masked} 2022-03-08 11:04:45.459 DEBUG 46576 --- [nio-8080-exec-3] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to com.example.demo.RestAPIExample#getTweetsByEmail(String) 2022-03-08 11:04:45.464 DEBUG 46576 --- [nio-8080-exec-3] o.s.w.s.v.ContentNegotiatingViewResolver : Selected '/' given [/] 2022-03-08 11:04:45.464 DEBUG 46576 --- [nio-8080-exec-3] o.s.w.servlet.view.InternalResourceView : View name 'tweets', model {tweets=[com.example.demo.Tweet@3a7a85cb]} 2022-03-08 11:04:45.465 DEBUG 46576 --- [nio-8080-exec-3] o.s.w.servlet.view.InternalResourceView : Forwarding to [tweets] 2022-03-08 11:04:45.467 DEBUG 46576 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet : "FORWARD" dispatch for GET "/[email protected]", parameters={masked} 2022-03-08 11:04:45.470 DEBUG 46576 --- [nio-8080-exec-3] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped to ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath [resources/], classpath [static/], classpath [public/], ServletContext [/]] 2022-03-08 11:04:45.472 DEBUG 46576 --- [nio-8080-exec-3] o.s.w.s.r.ResourceHttpRequestHandler : Resource not found 2022-03-08 11:04:45.473 DEBUG 46576 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet : Exiting from "FORWARD" dispatch, status 404 2022-03-08 11:04:45.473 DEBUG 46576 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet : Completed 404 NOT_FOUND 2022-03-08 11:04:45.474 DEBUG 46576 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet : "ERROR" dispatch for GET "/[email protected]", parameters={masked} 2022-03-08 11:04:45.475 DEBUG 46576 --- [nio-8080-exec-3] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#error(HttpServletRequest) 2022-03-08 11:04:45.482 DEBUG 46576 --- [nio-8080-exec-3] o.s.w.s.m.m.a.HttpEntityMethodProcessor : Using 'application/json', given [/] and supported [application/json, application/+json, application/json, application/+json] 2022-03-08 11:04:45.483 DEBUG 46576 --- [nio-8080-exec-3] o.s.w.s.m.m.a.HttpEntityMethodProcessor : Writing [{timestamp=Tue Mar 08 11:04:45 IST 2022, status=404, error=Not Found, path=/tweet2}] 2022-03-08 11:04:45.497 DEBUG 46576 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet : Exiting from "ERROR" dispatch, status 404


Here is the code I wrote:

@GetMapping("/tweet2")
    public ModelAndView getTweetsByEmail(@RequestParam String email) {
        ModelAndView modelAndView = new ModelAndView("tweets");
        List<Tweet> tweets = tweetMap.get(email);
        modelAndView.getModel().put("tweets",tweets);
        return modelAndView;
    }

And there is a tweets.mustache file under the resources folder. Not sure why its unable to detect it



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source