Spring Framework ContentNegotiatingViewResolver - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework ContentNegotiatingViewResolver class.

This code example shows how to use the following methods:setDefaultViews, setMediaTypes, setOrder
This code example shows how to use the following methods:setContentNegotiationManager, setViewResolvers
		resolvers.add(internalResourceViewResolverJsp());
		//resolvers.add(urlBasedViewResolver()); 
		//resolvers.add(internalResourceViewResolverHtml()); 
		 
		// Create the CNVR plugging in the resolvers and the content-negotiation manager 
		ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver();
		resolver.setViewResolvers(resolvers);
		resolver.setContentNegotiationManager(manager);
		return resolver;
	} 
	 
	 
	public ViewResolver urlBasedViewResolver() {
		UrlBasedViewResolver result = new InternalResourceViewResolverChainable();
//		result.setPrefix("/WEB-INF/jsp/"); 
//		result.setSuffix(".jsp"); 
//		result.setOrder(0); 
		return result;
	} 
 
6
CodeRank
This code example shows how to use the following methods:setDefaultViews, setMediaTypes, setViewResolvers
    } 
 
 
    @Bean 
    public ContentNegotiatingViewResolver contentNegotiatingViewResolver() { 
        ContentNegotiatingViewResolver viewResolver = new ContentNegotiatingViewResolver(); 
        viewResolver.setMediaTypes(mediaTypes()); 
        viewResolver.setViewResolvers(viewResolvers()); 
        viewResolver.setDefaultViews(defaultViews()); 
        return viewResolver; 
    } 
 
    private Map<String, String> mediaTypes() { 
        return new HashMap<String, String>() {{ 
            put("html", "text/html"); 
            put("json", "application/json"); 
        }}; 
    } 
 
    private List<ViewResolver> viewResolvers() { 
5
CodeRank
This code example shows how to use the following methods:setContentNegotiationManager, setViewResolvers
        //resolvers.add(internalResourceViewResolverJsp()); 
        //resolvers.add(urlBasedViewResolver()); 
        resolvers.add(internalResourceViewResolverHtml());
         
        // Create the CNVR plugging in the resolvers and the content-negotiation manager 
        ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver();
        resolver.setViewResolvers(resolvers);
        resolver.setContentNegotiationManager(manager);
        return resolver;
    } 
     
     
    public ViewResolver urlBasedViewResolver() {
        UrlBasedViewResolver result = new InternalResourceViewResolver();
//      result.setPrefix("/WEB-INF/jsp/"); 
//      result.setSuffix(".jsp"); 
//      result.setOrder(0); 
        return result;
    } 
 
5
CodeRank
This code example shows how to use the following methods:setContentNegotiationManager, setViewResolvers
		resolvers.add(getTilesViewResolver()); 
		resolvers.add(getXmlViewResolver()); 
		resolvers.add(getJsonViewResolver()); 
		resolvers.add(getMarshallingXmlViewResolver()); 
 
		ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver(); 
		resolver.setContentNegotiationManager(manager); 
		resolver.setViewResolvers(resolvers); 
		return resolver; 
	} 
 
	// Other view resolvers defined directly to CNVR, no longer @Beans 
	private ViewResolver getTilesViewResolver() { 
		TilesViewResolver resolver = new TilesViewResolver(); 
		resolver.setContentType("text/html"); 
		return resolver; 
	} 
 
	private ViewResolver getXmlViewResolver() { 
		XmlViewResolver resolver = new XmlViewResolver(); 
5
CodeRank
This code example shows how to use the following methods:
 * Specialisation of {@link ContentNegotiatingViewResolver} that can extract multi-dot extensions, 
 * rather than just the last part. 
 *   
 * @author Robert Chatley (robert@metabroadcast.com) 
 */ 
public class ExtensionBasedContentNegotiatingViewResolver extends ContentNegotiatingViewResolver { 
 
	private ConcurrentMap<String, MediaType> mediaTypes = new ConcurrentHashMap<String, MediaType>(); 
 
	protected MediaType getMediaTypeFromFilename(String filename) { 
		String extension = getExtension(filename); 
		if (!StringUtils.hasText(extension)) { 
			return null; 
		} 
		extension = extension.toLowerCase(Locale.ENGLISH); 
		MediaType mediaType = mediaTypes.get(extension); 
		if (mediaType == null) { 
			return super.getMediaTypeFromFilename(filename); 
		} 
		return mediaType; 
4
CodeRank
This code example shows how to use the following methods:setContentNegotiationManager
	 * @return A CNVR instance. 
	 */ 
	@Bean 
	public ViewResolver contentNegotiatingViewResolver( 
			ContentNegotiationManager manager) { 
		ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver(); 
		resolver.setContentNegotiationManager(manager); 
		return resolver; 
	} 
} 
4
CodeRank
See Code Examples for Spring Framework ContentNegotiatingViewResolver Methods: