almeitus
May 6th, 2008, 05:10 PM
Maybe I'm going at this the wrong way, but I have something that works in the 2.5 release, but it no longer works once I upgraded to 2.5.4. I also noticed a lot has changed in AnnotationMethodHandlerAdapter between these two releases.
I'm creating RESTful webservices via SpringMVC. Here is a test case that works in 2.5, but does NOT work with 2.5.4
public class ParentController {
RequestMapping(method = RequestMethod.GET)
public void doGet(
HttpServletRequest req,
HttpServletResponse resp
) throws IOException, ServletException {
resp.sendError(HttpServletResponse.SC_METHOD_NOT_A LLOWED,
"GET is NOT allowed");
}
}
Point here is that parent would have a default impl for all HTTP methods, like not allowed, and children can implement supported methods as appropriate. Here is an example child:
@Controller
@RequestMapping("/child/test")
public class ChildController extends ParentController {
@RequestMapping(method = RequestMethod.GET)
public void doGet(
HttpServletRequest req,
HttpServletResponse resp,
@RequestParam("childId") String childId
) throws IOException, ServletException {
resp.getWriter().write(
"<response>I am GET for childId: " + childId + "</response>");
}
}
You'll notice that "child" also uses @RequestParam which is really slick for grabbing req params, which is one of the reasons I went this route as opposed to using SimpleServletHandlerAdapter and manually pulling the param(s) out of the req. Also, I have full binding support via this route too.
So, can anyone tell me, is this a bug? One other thing, if I take out the @RequestParam in child, it works under 2.5.4.
-Chris
I'm creating RESTful webservices via SpringMVC. Here is a test case that works in 2.5, but does NOT work with 2.5.4
public class ParentController {
RequestMapping(method = RequestMethod.GET)
public void doGet(
HttpServletRequest req,
HttpServletResponse resp
) throws IOException, ServletException {
resp.sendError(HttpServletResponse.SC_METHOD_NOT_A LLOWED,
"GET is NOT allowed");
}
}
Point here is that parent would have a default impl for all HTTP methods, like not allowed, and children can implement supported methods as appropriate. Here is an example child:
@Controller
@RequestMapping("/child/test")
public class ChildController extends ParentController {
@RequestMapping(method = RequestMethod.GET)
public void doGet(
HttpServletRequest req,
HttpServletResponse resp,
@RequestParam("childId") String childId
) throws IOException, ServletException {
resp.getWriter().write(
"<response>I am GET for childId: " + childId + "</response>");
}
}
You'll notice that "child" also uses @RequestParam which is really slick for grabbing req params, which is one of the reasons I went this route as opposed to using SimpleServletHandlerAdapter and manually pulling the param(s) out of the req. Also, I have full binding support via this route too.
So, can anyone tell me, is this a bug? One other thing, if I take out the @RequestParam in child, it works under 2.5.4.
-Chris