• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java FixedThemeResolver类的典型用法和代码示例

java 1次浏览

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

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

示例1: setUp

点赞 3

import org.springframework.web.servlet.theme.FixedThemeResolver; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	wac = new StaticWebApplicationContext();
	wac.setServletContext(new MockServletContext());

	// final Template expectedTemplate = new Template();
	fc = new FreeMarkerConfigurer();
	fc.setTemplateLoaderPaths("classpath:/", "file://" + System.getProperty("java.io.tmpdir"));
	fc.afterPropertiesSet();

	wac.getDefaultListableBeanFactory().registerSingleton("freeMarkerConfigurer", fc);
	wac.refresh();

	request = new MockHttpServletRequest();
	request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
	request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver());
	request.setAttribute(DispatcherServlet.THEME_RESOLVER_ATTRIBUTE, new FixedThemeResolver());
	response = new MockHttpServletResponse();
}
 

开发者ID:langtianya,
项目名称:spring4-understanding,
代码行数:20,
代码来源:FreeMarkerMacroTests.java

示例2: setUp

点赞 3

import org.springframework.web.servlet.theme.FixedThemeResolver; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	wac = new StaticWebApplicationContext();
	wac.setServletContext(new MockServletContext());

	final Template expectedTemplate = new Template();
	VelocityConfig vc = new VelocityConfig() {
		@Override
		public VelocityEngine getVelocityEngine() {
			return new TestVelocityEngine("test.vm", expectedTemplate);
		}
	};
	wac.getDefaultListableBeanFactory().registerSingleton("velocityConfigurer", vc);
	wac.refresh();

	request = new MockHttpServletRequest();
	request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
	request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver());
	request.setAttribute(DispatcherServlet.THEME_RESOLVER_ATTRIBUTE, new FixedThemeResolver());
	response = new MockHttpServletResponse();
}
 

开发者ID:langtianya,
项目名称:spring4-understanding,
代码行数:22,
代码来源:VelocityRenderTests.java

示例3: setUp

点赞 3

import org.springframework.web.servlet.theme.FixedThemeResolver; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	wac = new StaticWebApplicationContext();
	wac.setServletContext(new MockServletContext());

	final Template expectedTemplate = new Template();
	VelocityConfig vc = new VelocityConfig() {
		@Override
		public VelocityEngine getVelocityEngine() {
			return new TestVelocityEngine(TEMPLATE_FILE, expectedTemplate);
		}
	};
	wac.getDefaultListableBeanFactory().registerSingleton("velocityConfigurer", vc);
	wac.refresh();

	request = new MockHttpServletRequest();
	request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
	request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver());
	request.setAttribute(DispatcherServlet.THEME_RESOLVER_ATTRIBUTE, new FixedThemeResolver());
	response = new MockHttpServletResponse();
}
 

开发者ID:langtianya,
项目名称:spring4-understanding,
代码行数:22,
代码来源:VelocityMacroTests.java

示例4: createPageContext

点赞 3

import org.springframework.web.servlet.theme.FixedThemeResolver; //导入依赖的package包/类
protected MockPageContext createPageContext() {
	MockServletContext sc = new MockServletContext();
	SimpleWebApplicationContext wac = new SimpleWebApplicationContext();
	wac.setServletContext(sc);
	wac.setNamespace("test");
	wac.refresh();

	MockHttpServletRequest request = new MockHttpServletRequest(sc);
	MockHttpServletResponse response = new MockHttpServletResponse();
	if (inDispatcherServlet()) {
		request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
		LocaleResolver lr = new AcceptHeaderLocaleResolver();
		request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, lr);
		ThemeResolver tr = new FixedThemeResolver();
		request.setAttribute(DispatcherServlet.THEME_RESOLVER_ATTRIBUTE, tr);
		request.setAttribute(DispatcherServlet.THEME_SOURCE_ATTRIBUTE, wac);
	}
	else {
		sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
	}

	return new MockPageContext(sc, request, response);
}
 

开发者ID:langtianya,
项目名称:spring4-understanding,
代码行数:24,
代码来源:AbstractTagTests.java

示例5: registerMvcSingletons

点赞 3

import org.springframework.web.servlet.theme.FixedThemeResolver; //导入依赖的package包/类
private void registerMvcSingletons(StubWebApplicationContext cxt) {

		StandaloneConfiguration configuration = new StandaloneConfiguration();

		RequestMappingHandlerMapping handlerMapping = configuration.requestMappingHandlerMapping();
		handlerMapping.setServletContext(cxt.getServletContext());
		handlerMapping.setApplicationContext(cxt);
		cxt.addBean("requestMappingHandlerMapping", handlerMapping);

		RequestMappingHandlerAdapter handlerAdapter = configuration.requestMappingHandlerAdapter();
		handlerAdapter.setServletContext(cxt.getServletContext());
		handlerAdapter.setApplicationContext(cxt);
		handlerAdapter.afterPropertiesSet();
		cxt.addBean("requestMappingHandlerAdapter", handlerAdapter);

		cxt.addBean("handlerExceptionResolver", configuration.handlerExceptionResolver());

		cxt.addBeans(initViewResolvers(cxt));
		cxt.addBean(DispatcherServlet.LOCALE_RESOLVER_BEAN_NAME, this.localeResolver);
		cxt.addBean(DispatcherServlet.THEME_RESOLVER_BEAN_NAME, new FixedThemeResolver());
		cxt.addBean(DispatcherServlet.REQUEST_TO_VIEW_NAME_TRANSLATOR_BEAN_NAME, new DefaultRequestToViewNameTranslator());

		this.flashMapManager = new SessionFlashMapManager();
		cxt.addBean(DispatcherServlet.FLASH_MAP_MANAGER_BEAN_NAME, this.flashMapManager);
	}
 

开发者ID:deathspeeder,
项目名称:class-guard,
代码行数:26,
代码来源:StandaloneMockMvcBuilder.java

示例6: setUp

点赞 3

import org.springframework.web.servlet.theme.FixedThemeResolver; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	wac = new StaticWebApplicationContext();
	wac.setServletContext(new MockServletContext());

	// final Template expectedTemplate = new Template();
	fc = new FreeMarkerConfigurer();
	fc.setTemplateLoaderPaths(new String[] { "classpath:/", "file://" + System.getProperty("java.io.tmpdir") });
	fc.afterPropertiesSet();

	wac.getDefaultListableBeanFactory().registerSingleton("freeMarkerConfigurer", fc);
	wac.refresh();

	request = new MockHttpServletRequest();
	request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
	request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver());
	request.setAttribute(DispatcherServlet.THEME_RESOLVER_ATTRIBUTE, new FixedThemeResolver());
	response = new MockHttpServletResponse();
}
 

开发者ID:deathspeeder,
项目名称:class-guard,
代码行数:20,
代码来源:FreeMarkerMacroTests.java

示例7: setUp

点赞 3

import org.springframework.web.servlet.theme.FixedThemeResolver; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
	wac = new StaticWebApplicationContext();
	wac.setServletContext(new MockServletContext());

	final Template expectedTemplate = new Template();
	VelocityConfig vc = new VelocityConfig() {
		@Override
		public VelocityEngine getVelocityEngine() {
			return new TestVelocityEngine(TEMPLATE_FILE, expectedTemplate);
		}
	};
	wac.getDefaultListableBeanFactory().registerSingleton("velocityConfigurer", vc);
	wac.refresh();

	request = new MockHttpServletRequest();
	request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
	request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver());
	request.setAttribute(DispatcherServlet.THEME_RESOLVER_ATTRIBUTE, new FixedThemeResolver());
	response = new MockHttpServletResponse();
}
 

开发者ID:deathspeeder,
项目名称:class-guard,
代码行数:22,
代码来源:VelocityMacroTests.java

示例8: createPageContext

点赞 3

import org.springframework.web.servlet.theme.FixedThemeResolver; //导入依赖的package包/类
protected MockPageContext createPageContext() {
	MockServletContext sc = new MockServletContext();
	sc.addInitParameter("springJspExpressionSupport", "true");
	SimpleWebApplicationContext wac = new SimpleWebApplicationContext();
	wac.setServletContext(sc);
	wac.setNamespace("test");
	wac.refresh();

	MockHttpServletRequest request = new MockHttpServletRequest(sc);
	MockHttpServletResponse response = new MockHttpServletResponse();
	if (inDispatcherServlet()) {
		request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
		LocaleResolver lr = new AcceptHeaderLocaleResolver();
		request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, lr);
		ThemeResolver tr = new FixedThemeResolver();
		request.setAttribute(DispatcherServlet.THEME_RESOLVER_ATTRIBUTE, tr);
		request.setAttribute(DispatcherServlet.THEME_SOURCE_ATTRIBUTE, wac);
	}
	else {
		sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
	}

	return new MockPageContext(sc, request, response);
}
 

开发者ID:deathspeeder,
项目名称:class-guard,
代码行数:25,
代码来源:AbstractTagTests.java

示例9: createPageContext

点赞 3

import org.springframework.web.servlet.theme.FixedThemeResolver; //导入依赖的package包/类
protected MockPageContext createPageContext() {
    MockServletContext sc = new MockServletContext();
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(sc);
    wac.setNamespace("test");
    wac.registerSingleton("validator",
            org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.class);
    wac.refresh();

    MockHttpServletRequest request = new MockHttpServletRequest(sc);
    MockHttpServletResponse response = new MockHttpServletResponse();
    request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
    LocaleResolver lr = new AcceptHeaderLocaleResolver();
    request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, lr);
    ThemeResolver tr = new FixedThemeResolver();
    request.setAttribute(DispatcherServlet.THEME_RESOLVER_ATTRIBUTE, tr);
    request.setAttribute(DispatcherServlet.THEME_SOURCE_ATTRIBUTE, wac);

    return new MockPageContext(sc, request, response);
}
 

开发者ID:arey,
项目名称:spring-mvc-toolkit,
代码行数:21,
代码来源:TestHtml5InputTag.java

示例10: doTestUrlBasedViewResolverWithoutPrefixes

点赞 2

import org.springframework.web.servlet.theme.FixedThemeResolver; //导入依赖的package包/类
private void doTestUrlBasedViewResolverWithoutPrefixes(UrlBasedViewResolver vr) throws Exception {
	StaticWebApplicationContext wac = new StaticWebApplicationContext();
	wac.setServletContext(new MockServletContext());
	wac.refresh();
	vr.setApplicationContext(wac);
	vr.setContentType("myContentType");
	vr.setRequestContextAttribute("rc");

	View view = vr.resolveViewName("example1", Locale.getDefault());
	assertEquals("Correct view class", JstlView.class, view.getClass());
	assertEquals("Correct URL", "example1", ((InternalResourceView) view).getUrl());
	assertEquals("Correct textContentType", "myContentType", ((InternalResourceView) view).getContentType());

	view = vr.resolveViewName("example2", Locale.getDefault());
	assertEquals("Correct view class", JstlView.class, view.getClass());
	assertEquals("Correct URL", "example2", ((InternalResourceView) view).getUrl());
	assertEquals("Correct textContentType", "myContentType", ((InternalResourceView) view).getContentType());

	HttpServletRequest request = new MockHttpServletRequest(wac.getServletContext());
	HttpServletResponse response = new MockHttpServletResponse();
	request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
	request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver());
	request.setAttribute(DispatcherServlet.THEME_RESOLVER_ATTRIBUTE, new FixedThemeResolver());
	Map model = new HashMap();
	TestBean tb = new TestBean();
	model.put("tb", tb);
	view.render(model, request, response);
	assertTrue("Correct tb attribute", tb.equals(request.getAttribute("tb")));
	assertTrue("Correct rc attribute", request.getAttribute("rc") instanceof RequestContext);

	view = vr.resolveViewName("redirect:myUrl", Locale.getDefault());
	assertEquals("Correct view class", RedirectView.class, view.getClass());
	assertEquals("Correct URL", "myUrl", ((RedirectView) view).getUrl());
	assertSame("View not initialized as bean", wac, ((RedirectView) view).getApplicationContext());

	view = vr.resolveViewName("forward:myUrl", Locale.getDefault());
	assertEquals("Correct view class", InternalResourceView.class, view.getClass());
	assertEquals("Correct URL", "myUrl", ((InternalResourceView) view).getUrl());
}
 

开发者ID:langtianya,
项目名称:spring4-understanding,
代码行数:40,
代码来源:ViewResolverTests.java

示例11: registerMvcSingletons

点赞 2

import org.springframework.web.servlet.theme.FixedThemeResolver; //导入依赖的package包/类
private void registerMvcSingletons(StubWebApplicationContext wac) {
	StandaloneConfiguration config = new StandaloneConfiguration();
	config.setApplicationContext(wac);

	wac.addBeans(this.controllerAdvice);

	StaticRequestMappingHandlerMapping hm = config.getHandlerMapping();
	hm.setServletContext(wac.getServletContext());
	hm.setApplicationContext(wac);
	hm.afterPropertiesSet();
	hm.registerHandlers(this.controllers);
	wac.addBean("requestMappingHandlerMapping", hm);

	RequestMappingHandlerAdapter handlerAdapter = config.requestMappingHandlerAdapter();
	handlerAdapter.setServletContext(wac.getServletContext());
	handlerAdapter.setApplicationContext(wac);
	handlerAdapter.afterPropertiesSet();
	wac.addBean("requestMappingHandlerAdapter", handlerAdapter);

	wac.addBean("handlerExceptionResolver", config.handlerExceptionResolver());

	wac.addBeans(initViewResolvers(wac));
	wac.addBean(DispatcherServlet.LOCALE_RESOLVER_BEAN_NAME, this.localeResolver);
	wac.addBean(DispatcherServlet.THEME_RESOLVER_BEAN_NAME, new FixedThemeResolver());
	wac.addBean(DispatcherServlet.REQUEST_TO_VIEW_NAME_TRANSLATOR_BEAN_NAME, new DefaultRequestToViewNameTranslator());

	this.flashMapManager = new SessionFlashMapManager();
	wac.addBean(DispatcherServlet.FLASH_MAP_MANAGER_BEAN_NAME, this.flashMapManager);
}
 

开发者ID:langtianya,
项目名称:spring4-understanding,
代码行数:30,
代码来源:StandaloneMockMvcBuilder.java

示例12: getThemeResolver

点赞 2

import org.springframework.web.servlet.theme.FixedThemeResolver; //导入依赖的package包/类
/**
 * Gets the fixed theme resolver.
 *
 * @return the fixed theme resolver
 */
@Bean(name = "themeResolver")
public ThemeResolver getThemeResolver() {
  logger.debug("Instantiated fixedThemeResolver");
  FixedThemeResolver resolver = new FixedThemeResolver();
  resolver.setDefaultThemeName("theme-classic");
  return resolver;
}
 

开发者ID:psi-probe,
项目名称:psi-probe,
代码行数:13,
代码来源:ProbeConfig.java

示例13: doTestUrlBasedViewResolverWithoutPrefixes

点赞 2

import org.springframework.web.servlet.theme.FixedThemeResolver; //导入依赖的package包/类
private void doTestUrlBasedViewResolverWithoutPrefixes(UrlBasedViewResolver vr) throws Exception {
	StaticWebApplicationContext wac = new StaticWebApplicationContext();
	wac.setServletContext(new MockServletContext());
	wac.refresh();
	vr.setApplicationContext(wac);
	vr.setContentType("myContentType");
	vr.setRequestContextAttribute("rc");

	View view = vr.resolveViewName("example1", Locale.getDefault());
	assertEquals("Correct view class", JstlView.class, view.getClass());
	assertEquals("Correct URL", "example1", ((InternalResourceView) view).getUrl());
	assertEquals("Correct contentType", "myContentType", ((InternalResourceView) view).getContentType());

	view = vr.resolveViewName("example2", Locale.getDefault());
	assertEquals("Correct view class", JstlView.class, view.getClass());
	assertEquals("Correct URL", "example2", ((InternalResourceView) view).getUrl());
	assertEquals("Correct contentType", "myContentType", ((InternalResourceView) view).getContentType());

	HttpServletRequest request = new MockHttpServletRequest(wac.getServletContext());
	HttpServletResponse response = new MockHttpServletResponse();
	request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
	request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver());
	request.setAttribute(DispatcherServlet.THEME_RESOLVER_ATTRIBUTE, new FixedThemeResolver());
	Map model = new HashMap();
	TestBean tb = new TestBean();
	model.put("tb", tb);
	view.render(model, request, response);
	assertTrue("Correct tb attribute", tb.equals(request.getAttribute("tb")));
	assertTrue("Correct rc attribute", request.getAttribute("rc") instanceof RequestContext);

	view = vr.resolveViewName("redirect:myUrl", Locale.getDefault());
	assertEquals("Correct view class", RedirectView.class, view.getClass());
	assertEquals("Correct URL", "myUrl", ((RedirectView) view).getUrl());
	assertSame("View not initialized as bean", wac, ((RedirectView) view).getApplicationContext());

	view = vr.resolveViewName("forward:myUrl", Locale.getDefault());
	assertEquals("Correct view class", InternalResourceView.class, view.getClass());
	assertEquals("Correct URL", "myUrl", ((InternalResourceView) view).getUrl());
}
 

开发者ID:deathspeeder,
项目名称:class-guard,
代码行数:40,
代码来源:ViewResolverTests.java

示例14: testXmlViewResolver

点赞 2

import org.springframework.web.servlet.theme.FixedThemeResolver; //导入依赖的package包/类
@Test
public void testXmlViewResolver() throws Exception {
	StaticWebApplicationContext wac = new StaticWebApplicationContext();
	wac.registerSingleton("testBean", TestBean.class);
	wac.setServletContext(new MockServletContext());
	wac.refresh();
	TestBean testBean = (TestBean) wac.getBean("testBean");
	XmlViewResolver vr = new XmlViewResolver();
	vr.setLocation(new ClassPathResource("org/springframework/web/servlet/view/views.xml"));
	vr.setApplicationContext(wac);

	View view1 = vr.resolveViewName("example1", Locale.getDefault());
	assertTrue("Correct view class", TestView.class.equals(view1.getClass()));
	assertTrue("Correct URL", "/example1.jsp".equals(((InternalResourceView) view1).getUrl()));

	View view2 = vr.resolveViewName("example2", Locale.getDefault());
	assertTrue("Correct view class", JstlView.class.equals(view2.getClass()));
	assertTrue("Correct URL", "/example2new.jsp".equals(((InternalResourceView) view2).getUrl()));

	ServletContext sc = new MockServletContext();
	Map model = new HashMap();
	TestBean tb = new TestBean();
	model.put("tb", tb);

	HttpServletRequest request = new MockHttpServletRequest(sc);
	HttpServletResponse response = new MockHttpServletResponse();
	request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
	request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver());
	request.setAttribute(DispatcherServlet.THEME_RESOLVER_ATTRIBUTE, new FixedThemeResolver());
	view1.render(model, request, response);
	assertTrue("Correct tb attribute", tb.equals(request.getAttribute("tb")));
	assertTrue("Correct test1 attribute", "testvalue1".equals(request.getAttribute("test1")));
	assertTrue("Correct test2 attribute", testBean.equals(request.getAttribute("test2")));

	request = new MockHttpServletRequest(sc);
	response = new MockHttpServletResponse();
	request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
	request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver());
	request.setAttribute(DispatcherServlet.THEME_RESOLVER_ATTRIBUTE, new FixedThemeResolver());
	view2.render(model, request, response);
	assertTrue("Correct tb attribute", tb.equals(request.getAttribute("tb")));
	assertTrue("Correct test1 attribute", "testvalue1".equals(request.getAttribute("test1")));
	assertTrue("Correct test2 attribute", "testvalue2".equals(request.getAttribute("test2")));
}
 

开发者ID:langtianya,
项目名称:spring4-understanding,
代码行数:45,
代码来源:ViewResolverTests.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)