I am extending the HandlerMethodArgumentResolver
to get hold of a parameter annotated by a custom annotation
@RequestMapping(value = "/cases/{caseId}", params = "meta",
method = PUT, produces = APPLICATION_JSON_VALUE)
@ResponseBody
@ResponseStatus(HttpStatus.OK)
public String updateUIMetadata(
@RequestBody
@JsonData(schemaLocation = "schema/metadata_schema.json")
final String metadataJson) {
}
I want to get hold of the value in my string metadataJson
in my class, specifically in the resolveArgument
method. I know it has a MethodParameter
parameter, but is it possible to get hold of the actual value of the parameter which is passed along with the web request?
public class UpdateMetadataInterceptor implements HandlerMethodArgumentResolver {
@Override
public boolean supportsParameter(MethodParameter parameter) {
return parameter.hasParameterAnnotation(JsonData.class);
}
@Override
public String resolveArgument(MethodParameter parameter,
ModelAndViewContainer mavContainer, NativeWebRequest webRequest,
WebDataBinderFactory binderFactory) throws Exception {
System.out.println("Inside UpdateMetadata");
// TODO something with metadataJson
}
}