Skip to content

velocity template can't use "spring.velocity.charset" #3994

@niqiumao

Description

@niqiumao

VelocityAutoConfiguration.java

right now the code is:

        protected void applyProperties(VelocityEngineFactory factory) {
            factory.setResourceLoaderPath(this.properties.getResourceLoaderPath());
            factory.setPreferFileSystemAccess(this.properties.isPreferFileSystemAccess());
            Properties velocityProperties = new Properties();
            velocityProperties.putAll(this.properties.getProperties());
            factory.setVelocityProperties(velocityProperties);
        }

After fix the code is:

        protected void applyProperties(VelocityEngineFactory factory) {
            factory.setResourceLoaderPath(this.properties.getResourceLoaderPath());
            factory.setPreferFileSystemAccess(this.properties.isPreferFileSystemAccess());

            Properties velocityProperties = new Properties();
            velocityProperties.putAll(this.properties.getProperties());
                        velocityProperties.setProperty("input.encoding", this.properties.getCharset());
            factory.setVelocityProperties(velocityProperties);
        }

added code:

  velocityProperties.setProperty("input.encoding", this.properties.getCharset());

so that we can use the "spring.velocity.charset" this is ugly, but right now i can use UTF-8

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions