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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -