當前位置: 首頁>>代碼示例>>Java>>正文


Java ViewResolver.resolveViewName方法代碼示例

本文整理匯總了Java中org.springframework.web.servlet.ViewResolver.resolveViewName方法的典型用法代碼示例。如果您正苦於以下問題:Java ViewResolver.resolveViewName方法的具體用法?Java ViewResolver.resolveViewName怎麽用?Java ViewResolver.resolveViewName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.web.servlet.ViewResolver的用法示例。


在下文中一共展示了ViewResolver.resolveViewName方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getCandidateViews

import org.springframework.web.servlet.ViewResolver; //導入方法依賴的package包/類
private List<View> getCandidateViews(String viewName, Locale locale, List<MediaType> requestedMediaTypes)
		throws Exception {

	List<View> candidateViews = new ArrayList<View>();
	for (ViewResolver viewResolver : this.viewResolvers) {
		View view = viewResolver.resolveViewName(viewName, locale);
		if (view != null) {
			candidateViews.add(view);
		}
		for (MediaType requestedMediaType : requestedMediaTypes) {
			List<String> extensions = this.contentNegotiationManager.resolveFileExtensions(requestedMediaType);
			for (String extension : extensions) {
				String viewNameWithExtension = viewName + "." + extension;
				view = viewResolver.resolveViewName(viewNameWithExtension, locale);
				if (view != null) {
					candidateViews.add(view);
				}
			}
		}
	}
	if (!CollectionUtils.isEmpty(this.defaultViews)) {
		candidateViews.addAll(this.defaultViews);
	}
	return candidateViews;
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:26,代碼來源:ContentNegotiatingViewResolver.java

示例2: resolveView

import org.springframework.web.servlet.ViewResolver; //導入方法依賴的package包/類
/** Fetch a Spring View, initializing the resolvers if necessary. */
protected View resolveView(FrameJob task, String viewName) {
	if (resolvers == null) {
		ApplicationContext ctx = task.getResource(ApplicationContext.class);
		Map<String, ViewResolver> beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(ctx, ViewResolver.class, true, false);
		resolvers = new ArrayList<ViewResolver>(beans.values());
	}
	
	try {
		for (ViewResolver vr : resolvers) {
			View v = vr.resolveViewName(viewName, LocaleContextHolder.getLocale());
			if (v != null) {
				return v;
			}
		}
		return null;
	} catch (Exception ex) {
		throw new RuntimeException("Unable to resolve view: " + viewName, ex);
	}
}
 
開發者ID:KRMAssociatesInc,項目名稱:eHMP,代碼行數:21,代碼來源:SearchFrame.java

示例3: resolveViewName

import org.springframework.web.servlet.ViewResolver; //導入方法依賴的package包/類
public View resolveViewName(String viewName, Locale locale) throws Exception {
	String viewType = this.defaultViewType;
	viewName = StringUtils.stripStart(viewName, "/");
	int index = viewName.lastIndexOf(".");
	if(index > 0){
		viewType = viewName.substring(index + 1);
		if(!this.viewResolvers.containsKey(viewType)){
			viewType = this.defaultViewType;
		}
		viewName = viewName.substring(0, index);
	}
	ViewResolver viewResolver = this.viewResolvers.get(viewType);
	return viewResolver.resolveViewName(viewName, locale);
}
 
開發者ID:penggle,項目名稱:xproject,代碼行數:15,代碼來源:MultiViewResover.java

示例4: resolveViewName

import org.springframework.web.servlet.ViewResolver; //導入方法依賴的package包/類
public View resolveViewName(String viewName, Locale locale) throws Exception
{
	int n = viewName.lastIndexOf('.');
	if(n == (-1))
	{
		throw new Exception("No such ViewResolver.");
	}
	String suffix = viewName.substring(n + 1);
	ViewResolver resolver = viewResolvers.get(suffix);
	// viewName=viewName.substring(0,n);
	if(resolver != null)
		return resolver.resolveViewName(viewName, locale);
	throw new Exception("No ViewResolver for " + suffix);
}
 
開發者ID:skeychen,項目名稱:dswork,代碼行數:15,代碼來源:ViewResolverFactory.java

示例5: resolveViewName

import org.springframework.web.servlet.ViewResolver; //導入方法依賴的package包/類
@Override
public View resolveViewName(String viewName, Locale locale) throws Exception {
	for (ViewResolver viewResolver : this.viewResolvers) {
		View view = viewResolver.resolveViewName(viewName, locale);
		if (view != null) {
			return view;
		}
	}
	return null;
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:11,代碼來源:ViewResolverComposite.java

示例6: resolveView

import org.springframework.web.servlet.ViewResolver; //導入方法依賴的package包/類
private View resolveView(String viewName) throws Exception {
	for (ViewResolver vr : resolvers) {
		View v = vr.resolveViewName(viewName, LocaleContextHolder.getLocale());
		if (v != null) {
			return v;
		}
	}
	return null;
}
 
開發者ID:KRMAssociatesInc,項目名稱:eHMP,代碼行數:10,代碼來源:QueryMapper.java

示例7: resolveViewName

import org.springframework.web.servlet.ViewResolver; //導入方法依賴的package包/類
/**
 * Resolve the given view name into a View object (to be rendered).
 * <p>Default implementations asks all ViewResolvers of this dispatcher.
 * Can be overridden for custom resolution strategies, potentially based
 * on specific model attributes or request parameters.
 * @param viewName the name of the view to resolve
 * @param model the model to be passed to the view
 * @param request current portlet render request
 * @return the View object, or null if none found
 * @throws Exception if the view cannot be resolved
 * (typically in case of problems creating an actual View object)
 * @see ViewResolver#resolveViewName
 */
protected View resolveViewName(String viewName, Map<String, ?> model, PortletRequest request) throws Exception {
	for (ViewResolver viewResolver : this.viewResolvers) {
		View view = viewResolver.resolveViewName(viewName, request.getLocale());
		if (view != null) {
			return view;
		}
	}
	return null;
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:23,代碼來源:DispatcherPortlet.java

示例8: resolveViewName

import org.springframework.web.servlet.ViewResolver; //導入方法依賴的package包/類
/**
 * Resolve the given view name into a View object (to be rendered).
 * <p>Default implementations asks all ViewResolvers of this dispatcher.
 * Can be overridden for custom resolution strategies, potentially based
 * on specific model attributes or request parameters.
 * @param viewName the name of the view to resolve
 * @param model the model to be passed to the view
 * @param request current portlet render request
 * @return the View object, or null if none found
 * @throws Exception if the view cannot be resolved
 * (typically in case of problems creating an actual View object)
 * @see ViewResolver#resolveViewName
 */
protected View resolveViewName(String viewName, Map model, PortletRequest request) throws Exception {
	for (ViewResolver viewResolver : this.viewResolvers) {
		View view = viewResolver.resolveViewName(viewName, request.getLocale());
		if (view != null) {
			return view;
		}
	}
	return null;
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:23,代碼來源:DispatcherPortlet.java


注:本文中的org.springframework.web.servlet.ViewResolver.resolveViewName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。