use of org.springframework.web.servlet.view.InternalResourceViewResolver in project spring-boot by spring-projects.
the class WebConfig method viewResolver.
@Bean
public InternalResourceViewResolver viewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setPrefix("/WEB-INF/views/");
viewResolver.setSuffix(".jsp");
return viewResolver;
}
use of org.springframework.web.servlet.view.InternalResourceViewResolver in project spring-framework by spring-projects.
the class ViewResolutionTests method testJspOnly.
@Test
public void testJspOnly() throws Exception {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver("/WEB-INF/", ".jsp");
standaloneSetup(new PersonController()).setViewResolvers(viewResolver).build().perform(get("/person/Corea")).andExpect(status().isOk()).andExpect(model().size(1)).andExpect(model().attributeExists("person")).andExpect(forwardedUrl("/WEB-INF/person/show.jsp"));
}
use of org.springframework.web.servlet.view.InternalResourceViewResolver in project spring-framework by spring-projects.
the class ViewResolutionTests method testContentNegotiation.
@Test
public void testContentNegotiation() throws Exception {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setClassesToBeBound(Person.class);
List<View> viewList = new ArrayList<>();
viewList.add(new MappingJackson2JsonView());
viewList.add(new MarshallingView(marshaller));
ContentNegotiationManager manager = new ContentNegotiationManager(new HeaderContentNegotiationStrategy(), new FixedContentNegotiationStrategy(MediaType.TEXT_HTML));
ContentNegotiatingViewResolver cnViewResolver = new ContentNegotiatingViewResolver();
cnViewResolver.setDefaultViews(viewList);
cnViewResolver.setContentNegotiationManager(manager);
cnViewResolver.afterPropertiesSet();
MockMvc mockMvc = standaloneSetup(new PersonController()).setViewResolvers(cnViewResolver, new InternalResourceViewResolver()).build();
mockMvc.perform(get("/person/Corea")).andExpect(status().isOk()).andExpect(model().size(1)).andExpect(model().attributeExists("person")).andExpect(forwardedUrl("person/show"));
mockMvc.perform(get("/person/Corea").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON)).andExpect(jsonPath("$.person.name").value("Corea"));
mockMvc.perform(get("/person/Corea").accept(MediaType.APPLICATION_XML)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_XML)).andExpect(xpath("/person/name/text()").string(equalTo("Corea")));
}
use of org.springframework.web.servlet.view.InternalResourceViewResolver in project spring-boot by spring-projects.
the class DeviceDelegatingViewResolverAutoConfigurationTests method deviceDelegatingJspResourceViewResolver.
@Test
public void deviceDelegatingJspResourceViewResolver() throws Exception {
load("spring.mobile.devicedelegatingviewresolver.enabled:true");
assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class)).hasSize(1);
InternalResourceViewResolver internalResourceViewResolver = this.context.getBean(InternalResourceViewResolver.class);
assertLiteDeviceDelegatingViewResolver(internalResourceViewResolver, "deviceDelegatingJspViewResolver");
}
use of org.springframework.web.servlet.view.InternalResourceViewResolver in project spring-security-oauth by spring-projects.
the class WebMvcConfig method viewResolver.
@Bean
public ViewResolver viewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setPrefix("/WEB-INF/jsp/");
viewResolver.setSuffix(".jsp");
return viewResolver;
}
Aggregations