Nvelocity configuration details

Source: Internet
Author: User

Before velocityengine initialization, you can use extendedproperties to configure the nvelocity runtime environment parameters. After the velocityengine Init (extendedproperties) is executed, nvelocity combines custom configurations and default configurations. Nvelocity defines the default configuration item name in nvelocity. runtime. runtimeconstants and defines the values of all default configuration items in the embedded resource file nvelocity. runtime. defaults. nvelocity. properties. Some common configurations are listed below:

Template code:

Input. Encoding = ISO-8859-1 // template input Encoding
Output. Encoding = ISO-8859-1 // template output Encoding

# Foreach Configuration

Directive. foreach. Counter. Name = velocitycount // counter name
Directive. foreach. Counter. Initial. value = 1 // counter Initial Value
Directive. foreach. maxloops =-1 // The maximum number of cycles.-1 indicates that directive. foreach. iterator. Name = velocityhasnex by default. // iterator name

# Set Configuration

Directive. Set. null. Allowed = false // whether a null value can be set

# Include configuration

Directive. Include. Output. errormsg. Start = <! -- Include error: // The start string is prompted for the error message.
Directive. Include. Output. errormsg. End = see error log --> // the error message prompts the end string.

# Parse Configuration

Directive. parse. Max. Depth = 10 // resolution depth

Template loader Configuration

 

Resource. loader = file // template loader type. The default value is file. You can define multiple

File. Resource. loader. Description = velocity file resource loader // loader description
File. Resource. loader. Class = nvelocity. runtime. Resource. loader. fileresourceloader // loader Class Name
File. Resource. loader. Path =. // template path
File. Resource. loader. cache = false // whether to enable template Cache
File. Resource. loader. modificationcheckinterval = 2 // check the template Change Interval

Macro Configuration

velocimacro. permissions. allow. inline = true // whether it can be defined in the row
velocimacro. permissions. allow. inline. to. replace. global = false // whether the global definition can be replaced by intra-row definition
velocimacro. permissions. allow. inline. local. scope = false // whether the intra-row definition is only used for local use

Velocimacro. Context. localscope = false // whether the macro is used only for local
Velocimacro. Max. Depth = 20 // resolution depth

Velocimacro. Arguments. Strict = false // whether the strict mode is enabled for macro parameters

Resource Manager Configuration

Resource. Manager. Class = nvelocity. runtime. Resource. resourcemanagerimpl // manager class name
Resource. Manager. cache. Class = nvelocity. runtime. Resource. resourcecacheimpl // cache Class Name

Parser pool Configuration

Parser. Pool. Class = nvelocity. runtime. parserpoolimpl // resolution pool class name
Parser. Pool. size = 40 // initial size

#Evaluate Configuration

Directive. Evaluate. Context. Class = nvelocity. velocitycontext // name of the Question class

Configurable introspector configurations

Runtime. introspector. uberspect = nvelocity. util. introspection. uberspectimpl // default introspector Class Name In nvelocity, multiple configurations can be defined, such as the resource loader. Note that the incoming implementation class name must be:Class fullname;Assembly nameFormat, for example, a custom resource loader easynet. MVC. assemblyresourceloader,ProgramThe Set Name Is easynet. MVC, which should be defined as follows:

Code
Velocityengine Velocity =   New Velocityengine ();

Extendedproperties props= NewExtendedproperties ();

//Define a resource Loader
Props. addproperty (runtimeconstants. resource_loader,"Easynet. MVC. assemblyresourceloader; easynet. MVC");

//Initialization
Velocity. INIT (props );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.