本文整理汇总了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;
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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));
}