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
Post a Comment