spring - HandlerInterceptorAdapter.postHandle doesn't get called -
i populate pages variables, wont work:
public class pagepopulationinterceptor extends handlerinterceptoradapter { public void posthandle(modelmap map) { map.addattribute("hello", "world"); } } @configuration @enablewebmvc public class webmvcconfig extends webmvcconfigureradapter { public @override void addinterceptors(interceptorregistry registry) { registry.addinterceptor(new pagepopulationinterceptor()); } }
when putting ${hello}
on page it's empty.
note posthandle()
method has incorrect signature, therefore doesn't override actual method of handlerinterceptoradapter
. correct 1 is:
public void posthandle( httpservletrequest request, httpservletresponse response, object handler, modelandview modelandview) { ... }
you can prevent kind of problems annotating methods intended override superclass methods @override
:
@override public void posthandle(modelmap map) { ... }
in case compiler give error because method doesn't override anything.
Comments
Post a Comment