You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are using the @ResponseBody similar as indicated in the reference doc, like: @RequestMapping(value = "/something", method = RequestMethod.PUT) @ResponseBody
public String helloWorld() {
return "Hello World";
}
The returned String does get written to the response by the StringHttpMessageConverter (and the remote client is happy), but then the String goes on to be rendered as an InternalResourceView. Since the strings we are returning are not valid as internal resources, we see a ServletException that is, among other things, caught by our HandlerInterceptor.
One reason this is a problem is because we are mixing together some responses that are marshalled to XML, some that are returned as a strings via the ResponseBody, and others that are valid InternalResourceViews.
One approach may be that AnnotationMethodHandlerAdapter should return null instead of attempting to create a ModelAndView after this condition is met:
Andrew Ebaugh opened SPR-6148 and commented
We are using the
@ResponseBody
similar as indicated in the reference doc, like:@RequestMapping
(value = "/something", method = RequestMethod.PUT)@ResponseBody
public String helloWorld() {
return "Hello World";
}
The returned String does get written to the response by the StringHttpMessageConverter (and the remote client is happy), but then the String goes on to be rendered as an InternalResourceView. Since the strings we are returning are not valid as internal resources, we see a ServletException that is, among other things, caught by our HandlerInterceptor.
One reason this is a problem is because we are mixing together some responses that are marshalled to XML, some that are returned as a strings via the ResponseBody, and others that are valid InternalResourceViews.
One approach may be that AnnotationMethodHandlerAdapter should return null instead of attempting to create a ModelAndView after this condition is met:
AnnotationMethodHandlerAdapter.getModelAndView(..) :
if (returnValue != null && handlerMethod.isAnnotationPresent(ResponseBody.class)) {
handleRequestBody(returnValue, webRequest);
}
As it is, it proceeds to:
if (returnValue instanceof String) {
return new ModelAndView((String) returnValue).addAllObjects(implicitModel);
}
Affects: 3.0 M4
Attachments:
Referenced from: commits e49869e
The text was updated successfully, but these errors were encountered: