Java Code Examples for org.springframework.web.servlet.ViewResolver#resolveViewName()
The following examples show how to use
org.springframework.web.servlet.ViewResolver#resolveViewName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContentNegotiatingViewResolver.java From lams with GNU General Public License v2.0 | 6 votes |
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; }
Example 2
Source File: ContentNegotiatingViewResolver.java From spring4-understanding with Apache License 2.0 | 6 votes |
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; }
Example 3
Source File: ViewResolverComposite.java From spring-analysis-note with MIT License | 5 votes |
@Override @Nullable 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; }
Example 4
Source File: ContentNegotiatingViewResolver.java From spring-analysis-note with MIT License | 5 votes |
private List<View> getCandidateViews(String viewName, Locale locale, List<MediaType> requestedMediaTypes) throws Exception { List<View> candidateViews = new ArrayList<>(); if (this.viewResolvers != null) { Assert.state(this.contentNegotiationManager != null, "No ContentNegotiationManager set"); 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; }
Example 5
Source File: ViewResolverComposite.java From java-technology-stack with MIT License | 5 votes |
@Override @Nullable 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; }
Example 6
Source File: ContentNegotiatingViewResolver.java From java-technology-stack with MIT License | 5 votes |
private List<View> getCandidateViews(String viewName, Locale locale, List<MediaType> requestedMediaTypes) throws Exception { List<View> candidateViews = new ArrayList<>(); if (this.viewResolvers != null) { Assert.state(this.contentNegotiationManager != null, "No ContentNegotiationManager set"); 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; }
Example 7
Source File: MultiViewResolver.java From stategen with GNU Affero General Public License v3.0 | 5 votes |
/** * 根据 spring mvc return 的返回置的 后缀名快速解析. * * @param viewName the view name * @param locale the locale * @return the view * @throws Exception the exception * @see org.springframework.web.servlet.ViewResolver#resolveViewName(java.lang.String, java.util.Locale) */ public View resolveViewName(String viewName, Locale locale) throws Exception { ViewResolver viewResolver = null; if (viewResolverMap != null && null != viewName) { int idx = viewName.lastIndexOf('.'); if (idx > -1) { String suffix = viewName.substring(idx); viewResolver = viewResolverMap.get(suffix); } } if (viewResolver != null) { // if (logger.isDebugEnabled()) { // logger.debug(new StringBuffer("找到 viewResolver:").append(viewName).toString()); // } } else { if (defaultViewResolver != null) { if (logger.isDebugEnabled()) { logger.debug(new StringBuffer("没找到 viewResolver:").append(viewName).append(",启用缺省的viewResolver") .toString()); } viewResolver = defaultViewResolver; } } if (viewResolver != null) { return viewResolver.resolveViewName(viewName, locale); } return null; }
Example 8
Source File: ViewResolverComposite.java From lams with GNU General Public License v2.0 | 5 votes |
@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; }
Example 9
Source File: ViewResolverComposite.java From spring4-understanding with Apache License 2.0 | 5 votes |
@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; }
Example 10
Source File: MvcViewRender.java From onetwo with Apache License 2.0 | 5 votes |
protected View resolveViewName(String viewName, Map<String, Object> model, Locale locale, HttpServletRequest request) throws Exception { for (ViewResolver viewResolver : this.viewResolvers) { View view = viewResolver.resolveViewName(viewName, locale); if (view != null) { return view; } } return null; }
Example 11
Source File: DispatcherPortlet.java From spring4-understanding with Apache License 2.0 | 3 votes |
/** * 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; }