I test a very simple Spring MVC example .code:
*/
@Controller
public class TestResponse {
@RequestMapping(method=RequestMethod.GET, value="/test/emp/1",
headers="Accept=application/json")
public @ResponseBody Employee getEmp() {
Employee e = new Employee("ad", "asdad");
System.out.println("Hello World");
return e;
}
}
and I test it through web browser..405!
DefaultHandlerExceptionResolver handleHttpRequestMethodNotSupported was thrown…
anyone can tell me how to fix it…and why?Thanks
Please give this a try.
Note the inclusion of a @RequestMapping at the class level.