See also
Baraha (free software)
References
External links
Official site
Category:Software programming tools
Category:Kannada-language software
Category:Concurrent programming languages
Category:Computer-related introductions in 2009Q:
Can I require a method to be called in every @ModelAttribute in my Spring REST controller?
I have a Spring REST controller which contains a few @ModelAttribute annotated methods, and in addition to these, there is a method that takes a @RequestParam and updates the attributes of that @ModelAttribute.
@RequestMapping(value = "/object", method = RequestMethod.POST)
public ModelAndView createObject(@RequestParam("title") String title,
@ModelAttribute("object") Object object,
BindingResult errors) {
// Do some validations here
// If validations fail, we return the error
ModelAndView modelAndView = new ModelAndView();
// I want to invoke this method here, as I know that the attributes have changed
_objectProcessor.process(title, object);
return modelAndView;
}
The problem is that I don't want to invoke this method in every @ModelAttribute method in my controller (as that would be very inefficient). Is there a way to do this? I'm using Spring 4.
A:
As you want to ensure the attributes are always correctly set, you should call _objectProcessor.process from ApplicationListener or ApplicationContextAware bean:
@Component
public class MyApplicationListener extends ApplicationListener {
@Autowired
private _objectProcessor;
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
_objectProcessor.process(/*...*/); ac619d1d87
Related links:
https://speedanporty.wixsite.com/piemotinpsearch/post/the-ultimate-fake-id-guide-2012-version-9
https://www.cakeresume.com/portfolios/assassin-s-creed-2-crack-only-skidrow-torrents-bla
https://www.aucklandshootingclub.org.nz/profile/reidardarkinnicholle/profile
https://rohnepanpsandu.wixsite.com/eskartipscho/post/aio-bot-crackbfdcm-schgas
Comments