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

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -