ContentNegotiatingViewResolverTests.java 文件源码

java
阅读 21 收藏 0 点赞 0 评论 0

项目:class-guard 作者:
@Test
public void nestedViewResolverIsNotSpringBean() throws Exception {
    StaticWebApplicationContext webAppContext = new StaticWebApplicationContext();
    webAppContext.setServletContext(new MockServletContext());
    webAppContext.refresh();

    InternalResourceViewResolver nestedResolver = new InternalResourceViewResolver();
    nestedResolver.setApplicationContext(webAppContext);
    nestedResolver.setViewClass(InternalResourceView.class);
    viewResolver.setViewResolvers(new ArrayList<ViewResolver>(Arrays.asList(nestedResolver)));

    FixedContentNegotiationStrategy fixedStrategy = new FixedContentNegotiationStrategy(MediaType.TEXT_HTML);
    viewResolver.setContentNegotiationManager(new ContentNegotiationManager(fixedStrategy));

    viewResolver.afterPropertiesSet();

    String viewName = "view";
    Locale locale = Locale.ENGLISH;

    View result = viewResolver.resolveViewName(viewName, locale);
    assertNotNull("Invalid view", result);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号