Hi all,
If I annotate an Object typed parameter with @RequestBody I get the SimpleSessionState object instead of the properly parsed body of the request.
Example:
I've traced the problem to the following line method in the org.springframework.web.method.support.InvocableHa ndlerMethod class.Code:public List<NetResponse> requester(HttpServletRequest request, HttpServletResponse response, Locale locale, @RequestBody Object bodyData) { if (bodyData instanceof Map){ processMap((Map)bodyData); } if (bodyData instanceof Collection){ processCollection((Collection)bodyData); } }
Code for actual Spring framework method.Code:args[i] = resolveProvidedArgument(parameter, providedArgs); if (args[i] != null) { continue; }
Because the parameter is of type Object it matches any providedArgs and the one that's provided in this case is the SimpleSessionStatus object.Code:private Object[] getMethodArgumentValues(NativeWebRequest request,* ModelAndViewContainer mavContainer,* Object... providedArgs) throws Exception { MethodParameter[] parameters = getMethodParameters(); Object[] args = new Object[parameters.length]; for (int i = 0; i < parameters.length; i++) { MethodParameter parameter = parameters[i]; parameter.initParameterNameDiscovery(this.parameterNameDiscoverer); GenericTypeResolver.resolveParameterType(parameter, getBean().getClass()); args[i] = resolveProvidedArgument(parameter, providedArgs); if (args[i] != null) { continue; } if (this.argumentResolvers.supportsParameter(parameter)) { args[i] = this.argumentResolvers.resolveArgument(parameter, mavContainer, request, dataBinderFactory); } else { throw new IllegalStateException("Cannot resolve argument index=" + parameter.getParameterIndex() + "" + ", name=" + parameter.getParameterName() + ", type=" + parameter.getParameterType() + " in method " + toString()); } } return args; }
Shouldn't the parameter checking look at the Annotations first so that an Object typed parameter can be used?
Thanks
Robert Brown


Reply With Quote