当前位置: 首页>>代码示例>>Java>>正文


Java InternalResourceViewResolver类代码示例

本文整理汇总了Java中org.springframework.web.servlet.view.InternalResourceViewResolver的典型用法代码示例。如果您正苦于以下问题:Java InternalResourceViewResolver类的具体用法?Java InternalResourceViewResolver怎么用?Java InternalResourceViewResolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


InternalResourceViewResolver类属于org.springframework.web.servlet.view包,在下文中一共展示了InternalResourceViewResolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getViewResolver

import org.springframework.web.servlet.view.InternalResourceViewResolver; //导入依赖的package包/类
private ViewResolver getViewResolver()
{
	InternalResourceViewResolver viewResolver = new InternalResourceViewResolver()
	{
		@Override
		protected AbstractUrlBasedView buildView(String viewName) throws Exception
		{
			String suffix = getSuffix();
			if (suffix != null && suffix.length() > 0 && viewName.endsWith(suffix))
			{
				viewName = viewName.substring(0, viewName.length() - suffix.length());
			}

			return super.buildView(viewName);
		}
	};
	viewResolver.setPrefix("/");
	viewResolver.setSuffix("");
	return viewResolver;
}
 
开发者ID:tmply,项目名称:tmply,代码行数:21,代码来源:WebMvcConfig.java

示例2: setupViewResolver

import org.springframework.web.servlet.view.InternalResourceViewResolver; //导入依赖的package包/类
@Bean
public InternalResourceViewResolver setupViewResolver() {
    InternalResourceViewResolver resolver = new InternalResourceViewResolver();
    resolver.setPrefix("/");
    resolver.setSuffix(".jsp");
    resolver.setContentType("text/html; charset-utf-8");
    resolver.setViewClass(JstlView.class);
    return resolver;
}
 
开发者ID:andrsam,项目名称:bookshelf,代码行数:10,代码来源:WebConfig.java

示例3: mvcViewResolver

import org.springframework.web.servlet.view.InternalResourceViewResolver; //导入依赖的package包/类
/**
 * Register a {@link ViewResolverComposite} that contains a chain of view resolvers
 * to use for view resolution.
 * By default this resolver is ordered at 0 unless content negotiation view
 * resolution is used in which case the order is raised to
 * {@link org.springframework.core.Ordered#HIGHEST_PRECEDENCE
 * Ordered.HIGHEST_PRECEDENCE}.
 * <p>If no other resolvers are configured,
 * {@link ViewResolverComposite#resolveViewName(String, Locale)} returns null in order
 * to allow other potential {@link ViewResolver} beans to resolve views.
 * @since 4.1
 */
@Bean
public ViewResolver mvcViewResolver() {
	ViewResolverRegistry registry = new ViewResolverRegistry();
	registry.setContentNegotiationManager(mvcContentNegotiationManager());
	registry.setApplicationContext(this.applicationContext);
	configureViewResolvers(registry);

	if (registry.getViewResolvers().isEmpty()) {
		String[] names = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(
				this.applicationContext, ViewResolver.class, true, false);
		if (names.length == 1) {
			registry.getViewResolvers().add(new InternalResourceViewResolver());
		}
	}

	ViewResolverComposite composite = new ViewResolverComposite();
	composite.setOrder(registry.getOrder());
	composite.setViewResolvers(registry.getViewResolvers());
	composite.setApplicationContext(this.applicationContext);
	composite.setServletContext(this.servletContext);
	return composite;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:35,代码来源:WebMvcConfigurationSupport.java

示例4: emptyParameterListHandleMethod

import org.springframework.web.servlet.view.InternalResourceViewResolver; //导入依赖的package包/类
@Test
public void emptyParameterListHandleMethod() throws Exception {
	@SuppressWarnings("serial") DispatcherServlet servlet = new DispatcherServlet() {
		@Override
		protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) {
			GenericWebApplicationContext wac = new GenericWebApplicationContext();
			wac.registerBeanDefinition("controller",
					new RootBeanDefinition(EmptyParameterListHandlerMethodController.class));
			RootBeanDefinition vrDef = new RootBeanDefinition(InternalResourceViewResolver.class);
			vrDef.getPropertyValues().add("suffix", ".jsp");
			wac.registerBeanDefinition("viewResolver", vrDef);
			wac.refresh();
			return wac;
		}
	};
	servlet.init(new MockServletConfig());

	MockHttpServletRequest request = new MockHttpServletRequest("GET", "/emptyParameterListHandler");
	MockHttpServletResponse response = new MockHttpServletResponse();

	EmptyParameterListHandlerMethodController.called = false;
	servlet.service(request, response);
	assertTrue(EmptyParameterListHandlerMethodController.called);
	assertEquals("", response.getContentAsString());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:26,代码来源:ServletAnnotationControllerTests.java

示例5: emptyParameterListHandleMethod

import org.springframework.web.servlet.view.InternalResourceViewResolver; //导入依赖的package包/类
@Test
public void emptyParameterListHandleMethod() throws Exception {
	initServlet(new ApplicationContextInitializer<GenericWebApplicationContext>() {
		@Override
		public void initialize(GenericWebApplicationContext context) {
			RootBeanDefinition vrDef = new RootBeanDefinition(InternalResourceViewResolver.class);
			vrDef.getPropertyValues().add("suffix", ".jsp");
			context.registerBeanDefinition("viewResolver", vrDef);
		}
	}, EmptyParameterListHandlerMethodController.class);

	MockHttpServletRequest request = new MockHttpServletRequest("GET", "/emptyParameterListHandler");
	MockHttpServletResponse response = new MockHttpServletResponse();

	EmptyParameterListHandlerMethodController.called = false;
	getServlet().service(request, response);
	assertTrue(EmptyParameterListHandlerMethodController.called);
	assertEquals("", response.getContentAsString());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:ServletAnnotationControllerHandlerMethodTests.java

示例6: withNoViewAndSamePath

import org.springframework.web.servlet.view.InternalResourceViewResolver; //导入依赖的package包/类
@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();
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:DispatcherServletTests.java

示例7: viewResolver

import org.springframework.web.servlet.view.InternalResourceViewResolver; //导入依赖的package包/类
@Bean
public ViewResolver viewResolver() {
	ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver();
	
	List<View> defaultViews = new ArrayList<View>();
	defaultViews.add(new MappingJackson2JsonView());
	resolver.setDefaultViews(defaultViews);
	resolver.setOrder(0);
	
	List<ViewResolver> viewResolvers = new ArrayList<ViewResolver>();
	InternalResourceViewResolver internalResourceViewResolver = new InternalResourceViewResolver();
	internalResourceViewResolver.setPrefix("/WEB-INF/view/");
	internalResourceViewResolver.setSuffix(".jsp");
	internalResourceViewResolver.setOrder(1);
	viewResolvers.add(internalResourceViewResolver);
	resolver.setViewResolvers(viewResolvers);
	
	return resolver;
}
 
开发者ID:EnterKey,项目名称:enterkey-framework,代码行数:20,代码来源:Application.java

示例8: deviceDelegatingThymeleafViewResolverEnabled

import org.springframework.web.servlet.view.InternalResourceViewResolver; //导入依赖的package包/类
@Test
public void deviceDelegatingThymeleafViewResolverEnabled() throws Exception {
	this.context = new AnnotationConfigEmbeddedWebApplicationContext();
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.mobile.devicedelegatingviewresolver.enabled:true");
	this.context.register(Config.class, WebMvcAutoConfiguration.class,
			ThymeleafAutoConfiguration.class,
			HttpMessageConvertersAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class,
			DeviceDelegatingViewResolverConfiguration.class);
	this.context.refresh();
	ThymeleafViewResolver thymeleafViewResolver = this.context
			.getBean(ThymeleafViewResolver.class);
	AbstractDeviceDelegatingViewResolver deviceDelegatingViewResolver = this.context
			.getBean("deviceDelegatingViewResolver",
					AbstractDeviceDelegatingViewResolver.class);
	assertThat(thymeleafViewResolver).isNotNull();
	assertThat(deviceDelegatingViewResolver).isNotNull();
	assertThat(deviceDelegatingViewResolver.getViewResolver())
			.isInstanceOf(ThymeleafViewResolver.class);
	assertThat(this.context.getBean(InternalResourceViewResolver.class)).isNotNull();
	assertThat(this.context.getBean(ThymeleafViewResolver.class)).isNotNull();
	assertThat(deviceDelegatingViewResolver.getOrder())
			.isEqualTo(thymeleafViewResolver.getOrder() - 1);
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:26,代码来源:DeviceDelegatingViewResolverAutoConfigurationTests.java

示例9: deviceDelegatingThymeleafViewResolverDisabled

import org.springframework.web.servlet.view.InternalResourceViewResolver; //导入依赖的package包/类
@Test(expected = NoSuchBeanDefinitionException.class)
public void deviceDelegatingThymeleafViewResolverDisabled() throws Exception {
	this.context = new AnnotationConfigEmbeddedWebApplicationContext();
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.mobile.devicedelegatingviewresolver.enabled:false");
	this.context.register(Config.class, WebMvcAutoConfiguration.class,
			ThymeleafAutoConfiguration.class,
			HttpMessageConvertersAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class,
			DeviceDelegatingViewResolverConfiguration.class);
	this.context.refresh();
	assertThat(this.context.getBean(InternalResourceViewResolver.class)).isNotNull();
	assertThat(this.context.getBean(ThymeleafViewResolver.class)).isNotNull();
	this.context.getBean("deviceDelegatingViewResolver",
			AbstractDeviceDelegatingViewResolver.class);
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:17,代码来源:DeviceDelegatingViewResolverAutoConfigurationTests.java

示例10: deviceDelegatingInternalResourceViewResolverDisabled

import org.springframework.web.servlet.view.InternalResourceViewResolver; //导入依赖的package包/类
@Test(expected = NoSuchBeanDefinitionException.class)
public void deviceDelegatingInternalResourceViewResolverDisabled() throws Exception {
	this.context = new AnnotationConfigEmbeddedWebApplicationContext();
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.mobile.devicedelegatingviewresolver.enabled:false");
	this.context.register(Config.class, WebMvcAutoConfiguration.class,
			HttpMessageConvertersAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class,
			DeviceDelegatingViewResolverConfiguration.class);
	this.context.refresh();
	assertNotNull(this.context.getBean(InternalResourceViewResolver.class));
	try {
		this.context.getBean(ThymeleafViewResolver.class);
	}
	catch (NoSuchBeanDefinitionException ex) {
		// expected. ThymeleafViewResolver shouldn't be defined.
	}
	this.context.getBean("deviceDelegatingViewResolver",
			AbstractDeviceDelegatingViewResolver.class);
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:21,代码来源:DeviceDelegatingViewResolverAutoConfigurationTests.java

示例11: deviceDelegatingThymeleafViewResolverEnabled

import org.springframework.web.servlet.view.InternalResourceViewResolver; //导入依赖的package包/类
@Test
public void deviceDelegatingThymeleafViewResolverEnabled() throws Exception {
	this.context = new AnnotationConfigEmbeddedWebApplicationContext();
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.mobile.devicedelegatingviewresolver.enabled:true");
	this.context.register(Config.class, WebMvcAutoConfiguration.class,
			ThymeleafAutoConfiguration.class,
			HttpMessageConvertersAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class,
			DeviceDelegatingViewResolverConfiguration.class);
	this.context.refresh();
	ThymeleafViewResolver thymeleafViewResolver = this.context
			.getBean(ThymeleafViewResolver.class);
	AbstractDeviceDelegatingViewResolver deviceDelegatingViewResolver = this.context
			.getBean("deviceDelegatingViewResolver",
					AbstractDeviceDelegatingViewResolver.class);
	assertNotNull(thymeleafViewResolver);
	assertNotNull(deviceDelegatingViewResolver);
	assertTrue(deviceDelegatingViewResolver
			.getViewResolver() instanceof ThymeleafViewResolver);
	assertNotNull(this.context.getBean(InternalResourceViewResolver.class));
	assertNotNull(this.context.getBean(ThymeleafViewResolver.class));
	assertTrue(deviceDelegatingViewResolver
			.getOrder() == thymeleafViewResolver.getOrder() - 1);
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:26,代码来源:DeviceDelegatingViewResolverAutoConfigurationTests.java

示例12: deviceDelegatingThymeleafViewResolverDisabled

import org.springframework.web.servlet.view.InternalResourceViewResolver; //导入依赖的package包/类
@Test(expected = NoSuchBeanDefinitionException.class)
public void deviceDelegatingThymeleafViewResolverDisabled() throws Exception {
	this.context = new AnnotationConfigEmbeddedWebApplicationContext();
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.mobile.devicedelegatingviewresolver.enabled:false");
	this.context.register(Config.class, WebMvcAutoConfiguration.class,
			ThymeleafAutoConfiguration.class,
			HttpMessageConvertersAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class,
			DeviceDelegatingViewResolverConfiguration.class);
	this.context.refresh();
	assertNotNull(this.context.getBean(InternalResourceViewResolver.class));
	assertNotNull(this.context.getBean(ThymeleafViewResolver.class));
	this.context.getBean("deviceDelegatingViewResolver",
			AbstractDeviceDelegatingViewResolver.class);
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:17,代码来源:DeviceDelegatingViewResolverAutoConfigurationTests.java

示例13: testWithNoViewAndSamePath

import org.springframework.web.servlet.view.InternalResourceViewResolver; //导入依赖的package包/类
public void testWithNoViewAndSamePath() 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();
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:18,代码来源:DispatcherServletTests.java

示例14: refresh

import org.springframework.web.servlet.view.InternalResourceViewResolver; //导入依赖的package包/类
@Override
public void refresh() throws BeansException {
	MutablePropertyValues pvs = new MutablePropertyValues();
	pvs.add("commandClass", "org.springframework.tests.sample.beans.TestBean");
	pvs.add("formView", "form");
	registerSingleton("/form.do", SimpleFormController.class, pvs);

	registerSingleton("/locale.do", LocaleChecker.class);

	addMessage("test", Locale.ENGLISH, "test message");
	addMessage("test", Locale.CANADA, "Canadian & test message");
	addMessage("testArgs", Locale.ENGLISH, "test {0} message {1}");
	addMessage("testArgsFormat", Locale.ENGLISH, "test {0} message {1,number,#.##} X");

	registerSingleton(UiApplicationContextUtils.THEME_SOURCE_BEAN_NAME, DummyThemeSource.class);

	registerSingleton("handlerMapping", BeanNameUrlHandlerMapping.class);
	registerSingleton("viewResolver", InternalResourceViewResolver.class);

	pvs = new MutablePropertyValues();
	pvs.add("location", "org/springframework/web/context/WEB-INF/sessionContext.xml");
	registerSingleton("viewResolver2", XmlViewResolver.class, pvs);

	super.refresh();
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:26,代码来源:SimpleWebApplicationContext.java

示例15: configureInternalResourceViewResolver

import org.springframework.web.servlet.view.InternalResourceViewResolver; //导入依赖的package包/类
@Bean
public InternalResourceViewResolver configureInternalResourceViewResolver() {
    InternalResourceViewResolver resolver = new InternalResourceViewResolver();
    resolver.setPrefix("/WEB-INF/views/");
    resolver.setSuffix(".jsp");
    return resolver;
}
 
开发者ID:cloudbees-attic,项目名称:spring-load-time-weaving-clickstart,代码行数:8,代码来源:WebConfig.java


注:本文中的org.springframework.web.servlet.view.InternalResourceViewResolver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。