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


Java FreeMarkerViewResolver类代码示例

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


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

示例1: freeMarkerConfigurer

import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; //导入依赖的package包/类
@Bean
	@ConditionalOnMissingBean({FreeMarkerConfig.class, FreeMarkerViewResolver.class})
	public FreeMarkerConfigurer freeMarkerConfigurer() {
		PluginFreeMarkerConfigurer configurer = new PluginFreeMarkerConfigurer();
		applyProperties(configurer);
		String[] paths = this.properties.getTemplateLoaderPath();
//		paths = ArrayUtils.add(paths, WEBFTLS_PATH);
		configurer.setTemplateLoaderPaths(paths);
		
		List<WithAnnotationBeanData<FreeMarkerViewTools>> tools = SpringUtils.getBeansWithAnnotation(applicationContext, FreeMarkerViewTools.class);
		tools.forEach(t->{
			String name = t.getAnnotation().value();
			if(StringUtils.isBlank(name)){
				name = t.getBean().getClass().getSimpleName();
			}
			configurer.setFreemarkerVariable(name, t.getBean());
			logger.info("registered FreeMarkerViewTools : {}", name);
		});
		return configurer;
	}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:21,代码来源:WebFtlsContextConfig.java

示例2: beforeMethod

import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; //导入依赖的package包/类
@BeforeMethod
public void beforeMethod()
{
	MockitoAnnotations.initMocks(this);
	FreeMarkerViewResolver freeMarkerViewResolver = new FreeMarkerViewResolver();
	freeMarkerViewResolver.setSuffix(".ftl");

	Menu menu = mock(Menu.class);
	when(menu.findMenuItemPath(MetadataManagerController.METADATA_MANAGER)).thenReturn("/test/path");
	when(menuReaderService.getMenu()).thenReturn(menu);

	when(appSettings.getLanguageCode()).thenReturn("nl");
	User user = mock(User.class);
	when(user.isSuperuser()).thenReturn(false);
	when(userAccountService.getCurrentUser()).thenReturn(user);

	MetadataManagerController metadataEditorController = new MetadataManagerController(menuReaderService,
			appSettings, metadataManagerService, userAccountService);

	mockMvc = MockMvcBuilders.standaloneSetup(metadataEditorController).setLocaleResolver(localeResolver)
							 .setMessageConverters(new FormHttpMessageConverter(), gsonHttpMessageConverter)
							 .build();
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:24,代码来源:MetadataManagerControllerTest.java

示例3: render

import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; //导入依赖的package包/类
private MockHttpServletResponse render(String viewName) throws Exception {
	FreeMarkerViewResolver resolver = this.context
			.getBean(FreeMarkerViewResolver.class);
	View view = resolver.resolveViewName(viewName, Locale.UK);
	assertThat(view).isNotNull();
	HttpServletRequest request = new MockHttpServletRequest();
	request.setAttribute(RequestContext.WEB_APPLICATION_CONTEXT_ATTRIBUTE,
			this.context);
	MockHttpServletResponse response = new MockHttpServletResponse();
	view.render(null, request, response);
	return response;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:FreeMarkerAutoConfigurationTests.java

示例4: getViewResolverFtl

import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; //导入依赖的package包/类
@Bean(name = "viewResolverFTL")
public FreeMarkerViewResolver getViewResolverFtl() {
    FreeMarkerViewResolver viewResolver = new FreeMarkerViewResolver();
    viewResolver.setPrefix("");
    viewResolver.setSuffix(".ftl");
    viewResolver.setOrder(1);
    return viewResolver;
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:9,代码来源:SpringContextConfig.java

示例5: freemarkerViewResolver

import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; //导入依赖的package包/类
@Bean
public FreeMarkerViewResolver freemarkerViewResolver() {
    FreeMarkerViewResolver resolver = new FreeMarkerViewResolver();
    resolver.setPrefix("");
    resolver.setCache(false);
    resolver.setOrder(3);
    return resolver;
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:9,代码来源:MailConfig.java

示例6: freeMarkerViewResolver

import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(name = "freeMarkerViewResolver")
@ConditionalOnProperty(name = "spring.freemarker.enabled", matchIfMissing = true)
public FreeMarkerViewResolver freeMarkerViewResolver() {
	FreeMarkerViewResolver resolver = new FreeMarkerViewResolver();
	this.properties.applyToViewResolver(resolver);
	return resolver;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:FreeMarkerAutoConfiguration.java

示例7: deviceDelegatingFreemarkerViewResolver

import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; //导入依赖的package包/类
@Bean
@ConditionalOnBean(FreeMarkerViewResolver.class)
public LiteDeviceDelegatingViewResolver deviceDelegatingFreemarkerViewResolver(
		DeviceDelegatingViewResolverFactory factory,
		FreeMarkerViewResolver viewResolver) {
	return factory.createViewResolver(viewResolver);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:DeviceDelegatingViewResolverAutoConfiguration.java

示例8: allowSessionOverride

import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; //导入依赖的package包/类
@Test
public void allowSessionOverride() {
	registerAndRefreshContext("spring.freemarker.allow-session-override:true");
	AbstractTemplateViewResolver viewResolver = this.context
			.getBean(FreeMarkerViewResolver.class);
	assertThat(ReflectionTestUtils.getField(viewResolver, "allowSessionOverride"))
			.isEqualTo(true);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:FreeMarkerAutoConfigurationTests.java

示例9: deviceDelegatingFreemarkerViewResolver

import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; //导入依赖的package包/类
@Test
public void deviceDelegatingFreemarkerViewResolver() throws Exception {
	load(Collections.<Class<?>>singletonList(FreeMarkerAutoConfiguration.class),
			"spring.mobile.devicedelegatingviewresolver.enabled:true");
	assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class))
			.hasSize(2);
	assertLiteDeviceDelegatingViewResolver(
			this.context.getBean(FreeMarkerViewResolver.class),
			"deviceDelegatingFreemarkerViewResolver");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:DeviceDelegatingViewResolverAutoConfigurationTests.java

示例10: viewResolver

import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; //导入依赖的package包/类
@Bean
public ViewResolver viewResolver() {
    FreeMarkerViewResolver resolver = new FreeMarkerViewResolver("", ".ftl");
    resolver.setCache(true);
    resolver.setPrefix("");
    return resolver;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:8,代码来源:AppFrontConfig.java

示例11: freeMarkerViewResolver

import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; //导入依赖的package包/类
@Bean
public FreeMarkerViewResolver freeMarkerViewResolver() {
    FreeMarkerViewResolver resolver = new FreeMarkerViewResolver();
    resolver.setCache(true);
    resolver.setPrefix("");
    resolver.setSuffix(".ftl");
    resolver.setContentType("text/html;charset=UTF-8");
    return resolver;
}
 
开发者ID:opensingular,项目名称:singular-server,代码行数:10,代码来源:ServerStudioWebMVCConfig.java

示例12: viewResolver

import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; //导入依赖的package包/类
@Bean
public FreeMarkerViewResolver viewResolver() {
    final FreeMarkerViewResolver resolver = new FreeMarkerViewResolver();
    resolver.setCache(true);
    resolver.setPrefix("");
    resolver.setSuffix(".ftl");
    resolver.setViewClass(FreeMarkerView.class);
    resolver.setContentType("text/html; charset=utf-8");
    resolver.setExposeSpringMacroHelpers(true);
    return resolver;
}
 
开发者ID:music-for-all,项目名称:music-for-all-application,代码行数:12,代码来源:WebAppConfig.java

示例13: init

import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; //导入依赖的package包/类
@Override
public void init() throws ServletException {
    ApplicationContext applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(
            getServletContext());
    freeMarkerViewResolver = applicationContext.getBean(FreeMarkerViewResolver.class);

    Method method = ReflectionUtils.findMethod(FreeMarkerViewResolver.class, "getSuffix");
    ReflectionUtils.makeAccessible(method);
    suffix = ReflectionUtils.invokeMethod(method, freeMarkerViewResolver).toString();

    inited = true;

    LOG.debug("spring freemarker servlet initialized, freemarker suffix [{}]", suffix);
}
 
开发者ID:kevin70,项目名称:setaria,代码行数:15,代码来源:SpringFreeMarkerServlet.java

示例14: configureKradWebApplicationContext

import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; //导入依赖的package包/类
/**
 * Create a web application context suitable for FreeMarker unit testing.
 */
private static void configureKradWebApplicationContext() {
    MockServletContext sctx = new MockServletContext();
    StaticWebApplicationContext ctx = new StaticWebApplicationContext();
    ctx.setServletContext(sctx);

    MutablePropertyValues mpv = new MutablePropertyValues();
    mpv.add("preferFileSystemAccess", false);
    mpv.add("templateLoaderPath", "/krad-web");
    Properties props = new Properties();
    props.put("number_format", "computer");
    props.put("template_update_delay", "2147483647");
    mpv.add("freemarkerSettings", props);
    ctx.registerSingleton("freemarkerConfig", FreeMarkerConfigurer.class, mpv);

    mpv = new MutablePropertyValues();
    mpv.add("cache", true);
    mpv.add("prefix", "");
    mpv.add("suffix", ".ftl");
    ctx.registerSingleton("viewResolver", FreeMarkerViewResolver.class, mpv);

    ctx.registerSingleton("freeMarkerInputBootstrap", FreeMarkerInlineRenderBootstrap.class);

    ctx.refresh();
    ctx.start();
    sctx.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ctx);
    webApplicationContext = ctx;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:31,代码来源:UifUnitTestUtils.java

示例15: allowSessionOverride

import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; //导入依赖的package包/类
@Test
public void allowSessionOverride() {
	registerAndRefreshContext("spring.freemarker.allow-session-override:true");
	AbstractTemplateViewResolver viewResolver = this.context
			.getBean(FreeMarkerViewResolver.class);
	assertThat((Boolean) ReflectionTestUtils.getField(viewResolver,
			"allowSessionOverride"), is(true));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:9,代码来源:FreeMarkerAutoConfigurationTests.java


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