本文整理匯總了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;
}
示例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);
}
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}