Skip to content

Commit 349300d

Browse files
GRAILS-6221 - improve view resolver handling in WebUtils.lookupViewResolver(ServletContext) to satisfy some failing tests. the real issue here may be some tests that need improving, pending investigation.
1 parent 3127487 commit 349300d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/java/org/codehaus/groovy/grails/web/util/WebUtils.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,18 @@ public class WebUtils extends org.springframework.web.util.WebUtils {
7373
private static final String GRAILS_DISPATCH_SERVLET_NAME = "/grails";
7474

7575
public static ViewResolver lookupViewResolver(ServletContext servletContext) {
76-
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
77-
return (ViewResolver)wac.getBean("jspViewResolver");
76+
WebApplicationContext wac = WebApplicationContextUtils
77+
.getRequiredWebApplicationContext(servletContext);
78+
if (wac.containsBean("jspViewResolver")) {
79+
return (ViewResolver) wac.getBean("jspViewResolver");
80+
} else {
81+
String[] beanNames = wac.getBeanNamesForType(ViewResolver.class);
82+
if (beanNames.length > 0) {
83+
String beanName = beanNames[0];
84+
return (ViewResolver) wac.getBean(beanName);
85+
}
86+
}
87+
return null;
7888
}
7989

8090
/**

0 commit comments

Comments
 (0)