java - @Secured in @Autowired controller does not work -


using @secured annotation in container @autowired not working.

@controller @requestmapping("/") public class hellocontroller {      @autowired     private applicationcontext applicationcontext;      @modelattribute     private string test() {         // applicationcontext null         return "test";     }      @secured("role_user")     @requestmapping(value = "test", method = requestmethod.get)     public string printwelcome(modelmap model) {         // applicationcontext null         model.addattribute("message", "hello world!");         return "hello";     } } 

i think problem when using @modelattribute method private, in runtime controller created proxy object in case, fails spring dependency injection. accessing property applicationcontext causes nullpointerexception.

i have never seen recommendation (or rule) create methods width @modelattribute annotation public. code works fine without @secured annotation.


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -