Java Code Examples for org.springframework.web.servlet.view.InternalResourceViewResolver#setSuffix()

The following examples show how to use org.springframework.web.servlet.view.InternalResourceViewResolver#setSuffix() . 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: DispatcherServletTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void withNoViewAndSamePath() throws Exception {
	InternalResourceViewResolver vr = (InternalResourceViewResolver) complexDispatcherServlet
			.getWebApplicationContext().getBean("viewResolver2");
	vr.setSuffix("");

	MockServletContext servletContext = new MockServletContext();
	MockHttpServletRequest request = new MockHttpServletRequest(servletContext, "GET", "/noview");
	MockHttpServletResponse response = new MockHttpServletResponse();

	try {
		complexDispatcherServlet.service(request, response);
		fail("Should have thrown ServletException");
	}
	catch (ServletException ex) {
		ex.printStackTrace();
	}
}
 
Example 2
Source File: MvcConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public ViewResolver viewResolver() {
    final InternalResourceViewResolver bean = new InternalResourceViewResolver();

    bean.setViewClass(JstlView.class);
    bean.setPrefix("/WEB-INF/view/");
    bean.setSuffix(".jsp");

    return bean;
}
 
Example 3
Source File: WebConfig.java    From springws with MIT License 5 votes vote down vote up
/**
 * 配置视图解析器
 */
@Bean
public ViewResolver viewResolver() {
    InternalResourceViewResolver resourceViewResolver = new InternalResourceViewResolver();
    resourceViewResolver.setPrefix("/WEB-INF/views/");
    resourceViewResolver.setSuffix(".jsp");
    resourceViewResolver.setExposeContextBeansAsAttributes(true);
    return resourceViewResolver;
}
 
Example 4
Source File: SpringMvcConfig.java    From Spring-5.0-Cookbook with MIT License 5 votes vote down vote up
@Bean
public InternalResourceViewResolver getViewResolver() {
    InternalResourceViewResolver resolver = new InternalResourceViewResolver();
    resolver.setPrefix("/WEB-INF/");
    resolver.setSuffix(".html");
    resolver.setOrder(3);
    return resolver;
}
 
Example 5
Source File: WebConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public ViewResolver viewResolver() {
    final InternalResourceViewResolver bean = new InternalResourceViewResolver();
    bean.setViewClass(JstlView.class);
    bean.setPrefix("/WEB-INF/view/");
    bean.setSuffix(".jsp");
    bean.setOrder(0);
    return bean;
}
 
Example 6
Source File: ClientWebConfigJava.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public ViewResolver viewResolver() {
    final InternalResourceViewResolver bean = new InternalResourceViewResolver();

    bean.setViewClass(JstlView.class);
    bean.setPrefix("/WEB-INF/view/");
    bean.setSuffix(".jsp");

    return bean;
}
 
Example 7
Source File: WebConfig.java    From Spring with Apache License 2.0 5 votes vote down vote up
@Bean
InternalResourceViewResolver getViewResolver(){
    InternalResourceViewResolver resolver = new InternalResourceViewResolver();
    resolver.setPrefix("/WEB-INF/");
    resolver.setSuffix(".jsp" );
    resolver.setRequestContextAttribute("requestContext");
    return resolver;
}
 
Example 8
Source File: SpringDispatcherConfig.java    From Spring-5.0-Cookbook with MIT License 5 votes vote down vote up
@Bean
public InternalResourceViewResolver jspViewResolver() {
    InternalResourceViewResolver viewResolverA = new InternalResourceViewResolver();
    viewResolverA.setPrefix("/WEB-INF/jsp/");
    viewResolverA.setSuffix(".jsp");
    viewResolverA.setOrder(1);
    return viewResolverA;
}
 
Example 9
Source File: FormControllerTests.java    From spring-tutorial with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
@Before
public void setup() throws Exception {

	InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
	viewResolver.setPrefix("/WEB-INF/");
	viewResolver.setSuffix(".jsp");

	this.mockMvc = standaloneSetup(new FormController()).setViewResolvers(viewResolver).build();
}
 
Example 10
Source File: WebConfig.java    From Project with Apache License 2.0 5 votes vote down vote up
@Bean
public ViewResolver viewResolver() {
	InternalResourceViewResolver resolver = new InternalResourceViewResolver();
	resolver.setPrefix("/WEB-INF/views/");
	resolver.setSuffix(".jsp");
	return resolver;
}
 
Example 11
Source File: ServletConfiguration.java    From airsonic-advanced with GNU General Public License v3.0 5 votes vote down vote up
@Bean
public ViewResolver jspViewResolver() {
    InternalResourceViewResolver resolver = new InternalResourceViewResolver();
    resolver.setViewClass(JstlView.class);
    resolver.setPrefix("/WEB-INF/jsp/");
    resolver.setSuffix(".jsp");
    return resolver;
}
 
Example 12
Source File: SpringDispatcherConfig.java    From Spring-5.0-Cookbook with MIT License 5 votes vote down vote up
@Bean
public InternalResourceViewResolver jspViewResolver() {
    InternalResourceViewResolver viewResolverA = new InternalResourceViewResolver();
    viewResolverA.setPrefix("/WEB-INF/jsp/");
    viewResolverA.setSuffix(".jsp");
    viewResolverA.setOrder(1);
    return viewResolverA;
}
 
Example 13
Source File: WebConfig.java    From nio-multipart with Apache License 2.0 5 votes vote down vote up
@Bean
public ViewResolver viewResolver() {
    InternalResourceViewResolver resolver = new InternalResourceViewResolver();
    resolver.setPrefix("/WEB-INF/views/");
    resolver.setSuffix(".jsp");
    resolver.setCache(false);
    resolver.setViewClass(JstlView.class);
    return resolver;
}
 
Example 14
Source File: WebConfig.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public ViewResolver viewResolver() {
    InternalResourceViewResolver resolver =
                      new InternalResourceViewResolver();
    resolver.setPrefix("/WEB-INF/jsp/");
    resolver.setSuffix(".jsp");
    resolver.setExposeContextBeansAsAttributes(true);
    return resolver;
}
 
Example 15
Source File: MvcConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public ViewResolver viewResolver() {
    final InternalResourceViewResolver bean = new InternalResourceViewResolver();

    bean.setViewClass(JstlView.class);
    bean.setPrefix("/WEB-INF/view/");
    bean.setSuffix(".jsp");

    return bean;
}
 
Example 16
Source File: WebConfig.java    From Spring with Apache License 2.0 5 votes vote down vote up
@Bean
public InternalResourceViewResolver getViewResolver(){
    final InternalResourceViewResolver resolver = new InternalResourceViewResolver();
    resolver.setSuffix("/WEB-INF/");
    resolver.setPrefix(".jsp");
    return resolver;
}
 
Example 17
Source File: WebConfig.java    From Spring with Apache License 2.0 5 votes vote down vote up
@Bean
public InternalResourceViewResolver getViewResolver(){
    final InternalResourceViewResolver resolver = new InternalResourceViewResolver();
    resolver.setPrefix("/WEB-INF/");
    resolver.setSuffix(".jsp" );
    return resolver;
}
 
Example 18
Source File: WebAppConfig.java    From logsniffer with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Defines view resolver.
 * 
 * @return
 */
@Bean
public ViewResolver viewResolver() {
	InternalResourceViewResolver resolver = new InternalResourceViewResolver();
	resolver.setPrefix("/WEB-INF/views/");
	resolver.setSuffix(".jsp");
	return resolver;
}
 
Example 19
Source File: TestWebAppConfig.java    From spring-blog with MIT License 5 votes vote down vote up
@Bean
public InternalResourceViewResolver jspViewResolver(){
	InternalResourceViewResolver resolver = new InternalResourceViewResolver();
	resolver.setPrefix("/WEB-INF/views/");
	resolver.setSuffix(".jsp");
	return resolver;
}
 
Example 20
Source File: WebMvcConfig.java    From spring-comparing-template-engines with Apache License 2.0 5 votes vote down vote up
@Bean
public ViewResolver chunkViewResolver() {
	InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
	viewResolver.setViewClass(ChunkTemplateView.class);
	viewResolver.setPrefix("/WEB-INF/chunk/");
	viewResolver.setViewNames("*-chunk");
	viewResolver.setSuffix(".chtml");
	viewResolver.setCache(false);
	viewResolver.setRequestContextAttribute("rc");
	viewResolver.setContentType("text/html;charset=UTF-8");

	return viewResolver;
}