Java 类org.springframework.web.servlet.view.velocity.VelocityConfigurer 实例源码

项目:hotel_shop    文件:VelocityConfig.java   
@Bean
    public VelocityConfigurer velocityConfig() {
        VelocityConfigurer cfg = new VelocityConfigurer();
        cfg.setResourceLoaderPath("/WEB-INF/velocity/");
        cfg.setPreferFileSystemAccess(true);
//      cfg.setConfigLocation(context.getResource("/WEB-INF/velocity.properties"));
        Properties velocityProperties = new Properties();
//      velocityProperties.put("velocimacro.permissions.allow.inline", "true");
//      velocityProperties.put("velocimacro.permissions.allow.inline.to.replace.global", "true");
//      velocityProperties.put("velocimacro.permissions.allow.inline.local.scope", "true");
//      velocityProperties.put("input.encoding", "UTF-8");
//      velocityProperties.put("output.encoding", "UTF-8");
//      velocityProperties.put("resource.loader", "webapp, class");
//      velocityProperties.put("class.resource.loader.description", "Velocity Classpath Resource Loader");
//      velocityProperties.put("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader ");
//      velocityProperties.put("webapp.resource.loader.class", "org.apache.velocity.tools.view.WebappResourceLoader");
//      velocityProperties.put("webapp.resource.loader.path", "/WEB-INF/velocity/");
//      velocityProperties.put("webapp.resource.loader.cache", "true");
        cfg.setVelocityProperties(velocityProperties);

        return cfg;
    }
项目:quartz-glass    文件:SpringConfig.java   
@Bean
public VelocityConfig velocityConfig() throws IOException, VelocityException {
    Properties config = new Properties();
    config.setProperty("input.encoding", "UTF-8");
    config.setProperty("output.encoding", "UTF-8");
    config.setProperty("default.contentType", "text/html;charset=UTF-8");
    config.setProperty("resource.loader", "class");
    config.setProperty("class.resource.loader.class",
            "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");

    VelocityConfigurer velocityConfigurer = new VelocityConfigurer();
    velocityConfigurer.setVelocityProperties(config);
    velocityConfigurer.afterPropertiesSet();

    return velocityConfigurer;
}
项目:ARCLib    文件:VelocityAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(VelocityConfig.class)
public VelocityConfigurer velocityConfigurer() {
    VelocityConfigurer configurer = new VelocityConfigurer();
    applyProperties(configurer);
    return configurer;
}
项目:spring4-understanding    文件:ViewResolverRegistry.java   
/**
 * Register Velocity view resolver with an empty default view name
 * prefix and a default suffix of ".vm".
 *
 * <p><strong>Note</strong> that you must also configure Velocity by adding a
 * {@link org.springframework.web.servlet.view.velocity.VelocityConfigurer} bean.
 */
public UrlBasedViewResolverRegistration velocity() {
    if (this.applicationContext != null && !hasBeanOfType(VelocityConfigurer.class)) {
        throw new BeanInitializationException("In addition to a Velocity view resolver " +
                "there must also be a single VelocityConfig bean in this web application context " +
                "(or its parent): VelocityConfigurer is the usual implementation. " +
                "This bean may be given any name.");
    }
    VelocityRegistration registration = new VelocityRegistration();
    this.viewResolvers.add(registration.getViewResolver());
    return registration;
}
项目:spring4-understanding    文件:ViewResolverRegistryTests.java   
@Before
public void setUp() {
    StaticWebApplicationContext context = new StaticWebApplicationContext();
    context.registerSingleton("freeMarkerConfigurer", FreeMarkerConfigurer.class);
    context.registerSingleton("velocityConfigurer", VelocityConfigurer.class);
    context.registerSingleton("tilesConfigurer", TilesConfigurer.class);
    context.registerSingleton("groovyMarkupConfigurer", GroovyMarkupConfigurer.class);
    context.registerSingleton("scriptTemplateConfigurer", ScriptTemplateConfigurer.class);
    this.registry = new ViewResolverRegistry();
    this.registry.setApplicationContext(context);
    this.registry.setContentNegotiationManager(new ContentNegotiationManager());
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:VelocityAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(VelocityConfig.class)
public VelocityConfigurer velocityConfigurer() {
    VelocityConfigurer configurer = new VelocityConfigurer();
    applyProperties(configurer);
    return configurer;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:VelocityAutoConfigurationTests.java   
@Test
public void customVelocitySettings() {
    registerAndRefreshContext(
            "spring.velocity.properties.directive.parse.max.depth:10");
    assertThat(this.context.getBean(VelocityConfigurer.class).getVelocityEngine()
            .getProperty("directive.parse.max.depth")).isEqualTo("10");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:VelocityAutoConfigurationTests.java   
@Test
public void renderTemplate() throws Exception {
    registerAndRefreshContext();
    VelocityConfigurer velocity = this.context.getBean(VelocityConfigurer.class);
    StringWriter writer = new StringWriter();
    Template template = velocity.getVelocityEngine().getTemplate("message.vm");
    template.process();
    VelocityContext velocityContext = new VelocityContext();
    velocityContext.put("greeting", "Hello World");
    template.merge(velocityContext, writer);
    assertThat(writer.toString()).contains("Hello World");
}
项目:ssm-shiro    文件:MVConfig.java   
/**
 * 过期是由于velocity六年没有更新过了,spring官方推荐使用FreeMarker或者Thymeleaf
 *
 * @return
 */
@Bean(name = "velocityConfig")
public VelocityConfigurer velocityConfigurer() {
    VelocityConfigurer configurer = new VelocityConfigurer();
    configurer.setResourceLoaderPath("/WEB-INF/template/");
    Properties properties = new Properties();

    //解决乱码问题
    properties.setProperty("input.encoding", "utf-8");
    properties.setProperty("output.encoding", "utf-8");
    configurer.setVelocityProperties(properties);
    return configurer;
}
项目:spring-boot-concourse    文件:VelocityAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(VelocityConfig.class)
public VelocityConfigurer velocityConfigurer() {
    VelocityConfigurer configurer = new VelocityConfigurer();
    applyProperties(configurer);
    return configurer;
}
项目:spring-boot-concourse    文件:VelocityAutoConfigurationTests.java   
@Test
public void customVelocitySettings() {
    registerAndRefreshContext(
            "spring.velocity.properties.directive.parse.max.depth:10");
    assertThat(this.context.getBean(VelocityConfigurer.class).getVelocityEngine()
            .getProperty("directive.parse.max.depth")).isEqualTo("10");
}
项目:spring-boot-concourse    文件:VelocityAutoConfigurationTests.java   
@Test
public void renderTemplate() throws Exception {
    registerAndRefreshContext();
    VelocityConfigurer velocity = this.context.getBean(VelocityConfigurer.class);
    StringWriter writer = new StringWriter();
    Template template = velocity.getVelocityEngine().getTemplate("message.vm");
    template.process();
    VelocityContext velocityContext = new VelocityContext();
    velocityContext.put("greeting", "Hello World");
    template.merge(velocityContext, writer);
    assertThat(writer.toString()).contains("Hello World");
}
项目:contestparser    文件:VelocityAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(VelocityConfig.class)
public VelocityConfigurer velocityConfigurer() {
    VelocityConfigurer configurer = new VelocityConfigurer();
    applyProperties(configurer);
    return configurer;
}
项目:contestparser    文件:VelocityAutoConfigurationTests.java   
@Test
public void customVelocitySettings() {
    registerAndRefreshContext(
            "spring.velocity.properties.directive.parse.max.depth:10");
    assertThat(
            this.context.getBean(VelocityConfigurer.class).getVelocityEngine()
                    .getProperty("directive.parse.max.depth"),
            equalTo((Object) "10"));
}
项目:contestparser    文件:VelocityAutoConfigurationTests.java   
@Test
public void renderTemplate() throws Exception {
    registerAndRefreshContext();
    VelocityConfigurer velocity = this.context.getBean(VelocityConfigurer.class);
    StringWriter writer = new StringWriter();
    Template template = velocity.getVelocityEngine().getTemplate("message.vm");
    template.process();
    VelocityContext velocityContext = new VelocityContext();
    velocityContext.put("greeting", "Hello World");
    template.merge(velocityContext, writer);
    assertThat(writer.toString(), containsString("Hello World"));
}
项目:orchidae    文件:WebMvcConfig.java   
@Bean
public VelocityConfig velocityConfig()
{
    Properties p = new Properties();
    p.put( "resource.loader", "webapp" );
    p.put( "webapp.resource.loader.path", new File( webapp, "html" ).toString() );
    p.put( "webapp.resource.loader.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader" );
    VelocityConfigurer vc = new VelocityConfigurer();
    VelocityEngine engine = new VelocityEngine( p );
    engine.init();
    vc.setVelocityEngine( engine );
    return vc;
}
项目:ARCLib    文件:VelocityAutoConfiguration.java   
@Bean
public VelocityEngine velocityEngine(VelocityConfigurer configurer)
        throws VelocityException, IOException {
    return configurer.getVelocityEngine();
}
项目:spring4-understanding    文件:ViewResolutionIntegrationTests.java   
@Bean
public VelocityConfigurer velocityConfigurer() {
    VelocityConfigurer configurer = new VelocityConfigurer();
    configurer.setResourceLoaderPath("/WEB-INF/");
    return configurer;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EmbeddedVelocityToolboxViewTests.java   
@Bean
public VelocityConfigurer velocityConfigurer() {
    return new VelocityConfigurer();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EmbeddedVelocityViewResolverTests.java   
@Bean
public VelocityConfigurer velocityConfigurer() {
    return new VelocityConfigurer();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EmbeddedVelocityViewResolverTests.java   
@Bean
public VelocityConfigurer velocityConfigurer() {
    return new VelocityConfigurer();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:VelocityAutoConfiguration.java   
@Bean
public VelocityEngine velocityEngine(VelocityConfigurer configurer)
        throws VelocityException, IOException {
    return configurer.getVelocityEngine();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:VelocityAutoConfigurationTests.java   
@Test
public void defaultConfiguration() {
    registerAndRefreshContext();
    assertThat(this.context.getBean(VelocityViewResolver.class)).isNotNull();
    assertThat(this.context.getBean(VelocityConfigurer.class)).isNotNull();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:VelocityAutoConfigurationTests.java   
@Test
public void customCharset() throws Exception {
    registerAndRefreshContext("spring.velocity.charset:ISO-8859-1");
    assertThat(this.context.getBean(VelocityConfigurer.class).getVelocityEngine()
            .getProperty("input.encoding")).isEqualTo("ISO-8859-1");
}
项目:spring-boot-concourse    文件:EmbeddedVelocityToolboxViewTests.java   
@Bean
public VelocityConfigurer velocityConfigurer() {
    return new VelocityConfigurer();
}
项目:spring-boot-concourse    文件:EmbeddedVelocityViewResolverTests.java   
@Bean
public VelocityConfigurer velocityConfigurer() {
    return new VelocityConfigurer();
}
项目:spring-boot-concourse    文件:EmbeddedVelocityViewResolverTests.java   
@Bean
public VelocityConfigurer velocityConfigurer() {
    return new VelocityConfigurer();
}
项目:spring-boot-concourse    文件:VelocityAutoConfiguration.java   
@Bean
public VelocityEngine velocityEngine(VelocityConfigurer configurer)
        throws VelocityException, IOException {
    return configurer.getVelocityEngine();
}
项目:spring-boot-concourse    文件:VelocityAutoConfigurationTests.java   
@Test
public void defaultConfiguration() {
    registerAndRefreshContext();
    assertThat(this.context.getBean(VelocityViewResolver.class)).isNotNull();
    assertThat(this.context.getBean(VelocityConfigurer.class)).isNotNull();
}
项目:spring-boot-concourse    文件:VelocityAutoConfigurationTests.java   
@Test
public void customCharset() throws Exception {
    registerAndRefreshContext("spring.velocity.charset:ISO-8859-1");
    assertThat(this.context.getBean(VelocityConfigurer.class).getVelocityEngine()
            .getProperty("input.encoding")).isEqualTo("ISO-8859-1");
}
项目:contestparser    文件:EmbeddedVelocityToolboxViewTests.java   
@Bean
public VelocityConfigurer velocityConfigurer() {
    return new VelocityConfigurer();
}
项目:contestparser    文件:EmbeddedVelocityViewResolverTests.java   
@Bean
public VelocityConfigurer velocityConfigurer() {
    return new VelocityConfigurer();
}
项目:contestparser    文件:EmbeddedVelocityViewResolverTests.java   
@Bean
public VelocityConfigurer velocityConfigurer() {
    return new VelocityConfigurer();
}
项目:contestparser    文件:VelocityAutoConfiguration.java   
@Bean
public VelocityEngine velocityEngine(VelocityConfigurer configurer)
        throws VelocityException, IOException {
    return configurer.getVelocityEngine();
}
项目:contestparser    文件:VelocityAutoConfigurationTests.java   
@Test
public void defaultConfiguration() {
    registerAndRefreshContext();
    assertThat(this.context.getBean(VelocityViewResolver.class), notNullValue());
    assertThat(this.context.getBean(VelocityConfigurer.class), notNullValue());
}
项目:contestparser    文件:VelocityAutoConfigurationTests.java   
@Test
public void customCharset() throws Exception {
    registerAndRefreshContext("spring.velocity.charset:ISO-8859-1");
    assertThat(this.context.getBean(VelocityConfigurer.class).getVelocityEngine()
            .getProperty("input.encoding"), equalTo((Object) "ISO-8859-1"));
}
项目:hotel_shop    文件:VelocityConfig.java   
@Bean
public VelocityEngine velocityEngine(VelocityConfigurer configurer) throws VelocityException, IOException {
    return configurer.getVelocityEngine();
}
项目:DCMonitor    文件:VelocityConfiguration.java   
@Bean
VelocityConfigurer velocityConfig() {
  return new VelocityConfigurer();
}
项目:boot-examples    文件:Application.java   
@Bean
VelocityConfigurer velocityConfig() {
    return new VelocityConfigurer();
}
项目:mongodb-aggregation    文件:Config.java   
@Bean
public VelocityConfigurer velocityConfig() {
    VelocityConfigurer velocityConfigurer = new VelocityConfigurer();
    velocityConfigurer.setResourceLoaderPath("/WEB-INF/html/");
    return velocityConfigurer;
}