dimanche 29 mars 2015

Spring AOP pass argument of a controller method

I have a controller as follows



@Controller
@RequestMapping(value = "/")
public class HomeController {
@RequestMapping("/")
public String home(Map<String,Object> map) {
map.put("val2","val2");
return "mainpage"; //it is the jsp file name
}
}


Now In my aspect class method I want to put another value in this map variable defined in the controller method



@Aspect
public class UserInfo {
@Before("execution(* org.controller.HomeController(..)) ")
public void m1(){
//Map<String,Object> map
// get the map here and add
map.put("val1","val1);
}
}


so that when i call this map form mainpage.jsp file I get both value as



${val1}
${val2}


How can I do this???


Aucun commentaire:

Enregistrer un commentaire