spring mvc - Intercept @RequestBody after serialization but before controller -


my request body objects implement interface call auditable, username , lastupdate timestamp set. intercept calls controller functions after serialization before hits controller can can these values in single place.

i looked @ handlerinterceptor.prehandle method executes before serialization. suggestion on how can make happen?

you can use controlleradvice , can in these scenarios. intercepts controller requests , can access serialized domain object in method. can pretty args requestmapping method takes. hope helps.

@controlleradvice public class controlleradvisor {      @modelattribute     public void addattributes(httpservletrequest request, httpservletresponse response,model model, @requestbody domainobject domain) {         domain.setusername("test");         // set other items want do.     }     } 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -