Java Code Examples for org.springframework.web.servlet.view.ContentNegotiatingViewResolver#setOrder()

The following examples show how to use org.springframework.web.servlet.view.ContentNegotiatingViewResolver#setOrder() . 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: DelegatingCatnapWebMvcConfiguration.java    From catnap with Apache License 2.0 6 votes vote down vote up
@Bean
public ContentNegotiatingViewResolver contentNegotiatingViewResolver() {
    List<View> defaultViews = new ArrayList<>(2);
    defaultViews.add(jsonCatnapSpringView());
    defaultViews.add(jsonpCatnapSpringView());

    List<CatnapWrappingView> catnapViews = new ArrayList<>(2);
    catnapViews.add(jsonCatnapSpringView());
    catnapViews.add(jsonpCatnapSpringView());

    CatnapViewResolver catnapViewResolver = new CatnapViewResolver();
    catnapViewResolver.setViews(catnapViews);

    List<ViewResolver> viewResolvers = new ArrayList<>(1);
    viewResolvers.add(catnapViewResolver);

    ContentNegotiatingViewResolver cnvr = new ContentNegotiatingViewResolver();
    cnvr.setContentNegotiationManager(mvcContentNegotiationManager());
    cnvr.setOrder(1);
    cnvr.setDefaultViews(defaultViews);
    cnvr.setViewResolvers(viewResolvers);

    return cnvr;
}
 
Example 2
Source File: WidgetConfiguration.java    From catnap with Apache License 2.0 6 votes vote down vote up
@Bean
public ContentNegotiatingViewResolver contentNegotiatingViewResolver() {
    List<View> defaultViews = new ArrayList<>(2);
    defaultViews.add(jsonCatnapSpringView());
    defaultViews.add(jsonpCatnapSpringView());

    List<CatnapWrappingView> catnapViews = new ArrayList<>(2);
    catnapViews.add(jsonCatnapSpringView());
    catnapViews.add(jsonpCatnapSpringView());

    CatnapViewResolver catnapViewResolver = new CatnapViewResolver();
    catnapViewResolver.setViews(catnapViews);

    List<ViewResolver> viewResolvers = new ArrayList<>(1);
    viewResolvers.add(catnapViewResolver);

    ContentNegotiatingViewResolver cnvr = new ContentNegotiatingViewResolver();
    cnvr.setContentNegotiationManager(mvcContentNegotiationManager());
    cnvr.setOrder(1);
    cnvr.setDefaultViews(defaultViews);
    cnvr.setViewResolvers(viewResolvers);

    return cnvr;
}