Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@RequestMapping Doesn't work- Did not find handler method

I have problem in getting the @RequestMapping to work, I get the following logs; could you please help me understand the log?

Log while booting:

DEBUG o.s.web.servlet.DispatcherServlet - DispatcherServlet with name 'dispatcherServlet' processing GET request for [/ruler/webjars/test]

DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Looking up handler method for path /webjars/test

DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Did not find handler method for [/webjars/test]

DEBUG o.s.w.s.h.SimpleUrlHandlerMapping - Matching patterns for request [/webjars/test] are [/webjars/, /]

DEBUG o.s.w.s.h.SimpleUrlHandlerMapping - URI Template variables for request [/webjars/test] are {}

DEBUG o.s.w.s.h.SimpleUrlHandlerMapping - Mapping [/webjars/test] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[class path resource [META-INF/resources/webjars/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@52454457]]] and 1 interceptor

DEBUG o.s.web.servlet.DispatcherServlet - Last-Modified value for [/ruler/webjars/test] is: -1

DEBUG o.s.web.servlet.DispatcherServlet - Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling

DEBUG o.s.web.servlet.DispatcherServlet - Successfully completed request

Log while accessing localhost:80/ruler/test:

DEBUG o.s.web.servlet.DispatcherServlet - DispatcherServlet with name 'dispatcherServlet' processing GET request for [/ruler/test]

DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Looking up handler method for path /test

DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Did not find handler method for [/test]

DEBUG o.s.w.s.h.SimpleUrlHandlerMapping - Matching patterns for request [/test] are [/**]

DEBUG o.s.w.s.h.SimpleUrlHandlerMapping - URI Template variables for request [/test] are {}

DEBUG o.s.w.s.h.SimpleUrlHandlerMapping - Mapping [/test] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/], ServletContext resource [/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@4538856f]]] and 1 interceptor

DEBUG o.s.web.servlet.DispatcherServlet - Last-Modified value for [/ruler/test] is: -1

DEBUG o.s.web.servlet.DispatcherServlet - Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling

DEBUG o.s.web.servlet.DispatcherServlet - Successfully completed request

Application.properties:

server.servlet.context-path=/ruler
server.port=80

RestController:

    @RestController
public class myController {
    private final MedicalService medicalService;

    @Autowired
    public myController(MedicalService medicalService) {
        this.medicalService = medicalService;
    }

    @RequestMapping(value="/test")
    public String testRest()
    {
        return "Yay";
    }
}

No web.xml.

like image 389
Ace Avatar asked Dec 08 '25 10:12

Ace


1 Answers

Found the answer to my problem here, it was because of project structure, not the configs.

App package should be like com.app then controller would be com.app.controller.

like image 107
Ace Avatar answered Dec 11 '25 12:12

Ace



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!