I’d like to be able to have the following:
@Controller
public class MyController {
@RequestMapping(value="/someurl", method=RequestMethod.GET)
@PreProcess
@PostProcess
public String doStuff(ModelMap map) {
//do stuff
return "someurl";
}
}
The @PreProcess and @PostProcess are arbitrarily named Annotations.
I’ve been looking for a working example of this but I can’t find any. I’ve looked at AOP and the use of the @Aspect annotation but I found it quite complex. A working example of what I’m trying to do would be great.
I’ve sampled Spring Security in the past but this isn’t quite what I need because I need the processing to be custom, pretty much anything I want.
I know that this functionality is available in .Net MVC. Hoping it’s available in Spring also.
Any help or pointers really appreciated.
You can annotate a method with
@ModelAttributeto execute a method before a controller method. Or use aninterceptorExample with
@ModelAttributeThe
something()method will be called before every method having a@RequestMappingannotation, thus before thedoStuff()method.