1 16 17 package org.springframework.web.servlet.view; 18 19 import java.util.Locale ; 20 21 import org.springframework.beans.BeansException; 22 import org.springframework.context.ApplicationContext; 23 import org.springframework.core.Ordered; 24 import org.springframework.web.context.support.WebApplicationObjectSupport; 25 import org.springframework.web.servlet.View; 26 import org.springframework.web.servlet.ViewResolver; 27 28 55 public class BeanNameViewResolver extends WebApplicationObjectSupport implements ViewResolver, Ordered { 56 57 private int order = Integer.MAX_VALUE; 59 60 public void setOrder(int order) { 61 this.order = order; 62 } 63 64 public int getOrder() { 65 return order; 66 } 67 68 69 public View resolveViewName(String viewName, Locale locale) throws BeansException { 70 ApplicationContext context = getApplicationContext(); 71 if (!context.containsBean(viewName)) { 72 return null; 74 } 75 return (View) context.getBean(viewName, View.class); 76 } 77 78 } 79 | Popular Tags |