*/
private ValidatorResources getValidatorResources() {
// look in servlet beans definition (i.e. action-servlet.xml)
WebApplicationContext ctx = (WebApplicationContext) pageContext.getRequest()
.getAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE);
ValidatorFactory factory = null;
try {
factory = (ValidatorFactory) BeanFactoryUtils
.beanOfTypeIncludingAncestors(ctx, ValidatorFactory.class, true, true);
} catch (NoSuchBeanDefinitionException e) {
// look in main application context (i.e. applicationContext.xml)
ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(pageContext.getServletContext());
factory = (ValidatorFactory) BeanFactoryUtils
.beanOfTypeIncludingAncestors(ctx, ValidatorFactory.class, true, true);
}
return factory.getValidatorResources();
}