Announcement Announcement Module
Collapse
No announcement yet.
problem with @RequestMapping Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • problem with @RequestMapping

    I am very new to Spring. I have created simple Controller with annotations. The problem is if i write my controller like that
    Code:
    @Controller
    public class NewOffererDataCaptureFormHandler {
    	@RequestMapping("/newOfferer.dc")
    	public String redirect(){
    	return "newOffererForm";
    }
    }
    It works fine. It shows my "newOffererForm" .
    But when i tried this code

    Code:
    @Controller
    @RequestMapping("/newOfferer.dc")
    public class NewOffererDataCaptureFormHandler {
    	public String redirect(){
    	return "newOffererForm";
    }
    }
    It gives me the following Run time exception
    SEVERE: Servlet.service() for servlet dataCapturer threw exception
    javax.servlet.ServletException: No adapter for handler : Does your handler implement a supported interface like Controller?

    why i tried this thing, because i found somewhere that we can put @RequestMapping annotations like that also. Did i do something wrong?
    thanks for advance..

  • #2
    Well, I think you need to provide a request mapping for your method also just like you did for the class.You might need to add something like
    Code:
    @RequestMapping(method = RequestMethod.POST)
    I hope this solves your problem.
    Cheers,
    Sushant

    Comment


    • #3
      Well it solved my problem. But i am not able to understand the reason behind that. It means if i add @Requestmapping to my method i have no need to add method annotations? in this case what will be requset method? GET or POST?

      Comment


      • #4
        Although you may have no @RequestMapping in the type level (controller works with default path) you should have at least one annotated method (even with no parameters) for the request to be handled

        Comment

        Working...
        X