Announcement Announcement Module
Collapse
No announcement yet.
how to configure Velocity and SpringResourceLoader? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to configure Velocity and SpringResourceLoader?

    I have been trying unsuccessfully to use
    org.framework.ui.velocity.SpringResourceLoader to enable Spring-style
    Resource loading with Velocity-1.5.

    VelocityEngineFactoryBean factory = new
    VelocityEngineFactoryBean();
    factory.setPreferFileSystemAccess(false);

    Properties velocityProperties = new Properties();
    velocityProperties.setProperty("resource.loader", "class");

    velocityProperties
    .setProperty("class.resource.loader.class",

    "org.apache.velocity.runtime.resource.loader.Class pathResourceLoader");
    /*
    This does not work....should it?
    velocityProperties.setProperty("class.resource.loa der.class",
    "org.springframework.ui.velocity.SpringResourceLoa der");
    */

    factory.setVelocityProperties(velocityProperties);
    VelocityEngine engine = factory.createVelocityEngine();

    // FAILS here...
    String result =
    VelocityEngineUtils.mergeTemplateIntoString(engine ,
    "classpath:templates/myTemplate.vm", null);

    What do I need to do, to enable the code to work with the "classpath:"
    prefix in the Template name?

    Can someone provide me with an example of how to configure the VelocityEngine to do this?
Working...
X