java - How to use RequestBodyAdvice -
@controlleradvice public class requestbodyadvicechain implements requestbodyadvice { @override public boolean supports(methodparameter methodparameter, type type, class< ? extends httpmessageconverter< ? >> aclass) { return true; } @override public object handleemptybody(object o, httpinputmessage httpinputmessage, methodparameter methodparameter, type type, class< ? extends httpmessageconverter< ? >> aclass) { return o; } @override public httpinputmessage beforebodyread(httpinputmessage httpinputmessage, methodparameter methodparameter, type type, class< ? extends httpmessageconverter< ? >> aclass) throws ioexception { return httpinputmessage; } @override public object afterbodyread(object o, httpinputmessage httpinputmessage, methodparameter methodparameter, type type, class< ? extends httpmessageconverter< ? >> aclass) { return o; } }
ideally, flow should reach these function first , go controller it's not working.
@controlleradvice
component should registered in spring's context other component. make sure spring sees component, e.q. including in @componentscan
(java config) or in <context:component-scan/>
(xml way). preferred context register dispatcher servlet's one.
Comments
Post a Comment