當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。