@Deprecated public class VelocityUtil extends Object
Constructor and Description |
---|
VelocityUtil()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
static String |
getContent(String templateDir,
String templateFileName,
org.apache.velocity.VelocityContext context,
String charset)
Deprecated.
获得指定模板填充后的内容
|
static String |
getContent(String templateFileName,
org.apache.velocity.VelocityContext context)
Deprecated.
获得指定模板填充后的内容,使用默认引擎
|
static String |
getContent(org.apache.velocity.app.VelocityEngine ve,
String templateFileName,
org.apache.velocity.VelocityContext context)
Deprecated.
获得指定模板填充后的内容
|
static void |
init(String templateDir,
String charset)
Deprecated.
初始化Velocity全局属性
|
static void |
init(String templateDir,
String charset,
Map<String,Object> initedGlobalContext)
Deprecated.
初始化全局属性
|
static String |
merge(String templateContent,
org.apache.velocity.VelocityContext context)
Deprecated.
融合模板和内容
|
static void |
merge(org.apache.velocity.Template template,
org.apache.velocity.VelocityContext context,
Writer writer)
Deprecated.
融合模板和内容并写入到Writer
|
static org.apache.velocity.app.VelocityEngine |
newEngine(String templateDir,
String charset)
Deprecated.
新建Velocity模板引擎
|
static org.apache.velocity.VelocityContext |
parseRequest(org.apache.velocity.VelocityContext context,
javax.servlet.http.HttpServletRequest request)
Deprecated.
将Request中的数据转换为模板引擎
取值包括Session和Request |
static org.apache.velocity.VelocityContext |
parseSession(org.apache.velocity.VelocityContext context,
javax.servlet.http.HttpSession session)
Deprecated.
将Session中的值放入模板上下文
|
void |
putGlobalContext(String name,
Object value)
Deprecated.
设置Velocity全局上下文
当设定值时,对于每个模板都有效 |
static void |
toFile(String templateFileName,
org.apache.velocity.VelocityContext context,
String destPath)
Deprecated.
生成文件,使用默认引擎
|
static void |
toFile(org.apache.velocity.Template template,
org.apache.velocity.VelocityContext context,
String destPath)
Deprecated.
生成文件
|
static void |
toFile(org.apache.velocity.app.VelocityEngine ve,
String templateFileName,
org.apache.velocity.VelocityContext context,
String destPath)
Deprecated.
生成文件
|
static void |
toWriter(String templateFileName,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Deprecated.
生成内容写到响应内容中
模板的变量来自于Request的Attribute对象 |
static void |
toWriter(String templateFileName,
org.apache.velocity.VelocityContext context,
Writer writer)
Deprecated.
生成内容写入流
会自动关闭Writer |
static void |
toWriter(org.apache.velocity.app.VelocityEngine ve,
String templateFileName,
org.apache.velocity.VelocityContext context,
Writer writer)
Deprecated.
生成内容写入流
会自动关闭Writer |
public void putGlobalContext(String name, Object value)
name
- 名value
- 值public static void init(String templateDir, String charset)
templateDir
- 模板所在目录,绝对路径charset
- 编码public static void init(String templateDir, String charset, Map<String,Object> initedGlobalContext)
templateDir
- 模板目录charset
- 字符集编码initedGlobalContext
- 初始的全局上下文public static org.apache.velocity.app.VelocityEngine newEngine(String templateDir, String charset)
templateDir
- 模板所在目录,绝对路径charset
- 编码public static String getContent(String templateDir, String templateFileName, org.apache.velocity.VelocityContext context, String charset)
templateDir
- 模板所在目录,绝对路径templateFileName
- 模板名称context
- 上下文(变量值的容器)charset
- 字符集public static String getContent(org.apache.velocity.app.VelocityEngine ve, String templateFileName, org.apache.velocity.VelocityContext context)
ve
- 模板引擎templateFileName
- 模板名称context
- 上下文(变量值的容器)public static String getContent(String templateFileName, org.apache.velocity.VelocityContext context)
templateFileName
- 模板文件context
- 上下文(变量值的容器)public static void toFile(org.apache.velocity.app.VelocityEngine ve, String templateFileName, org.apache.velocity.VelocityContext context, String destPath)
ve
- 模板引擎templateFileName
- 模板文件名context
- 上下文destPath
- 目标路径(绝对)public static void toFile(String templateFileName, org.apache.velocity.VelocityContext context, String destPath)
templateFileName
- 模板文件名context
- 模板上下文destPath
- 目标路径(绝对)public static void toFile(org.apache.velocity.Template template, org.apache.velocity.VelocityContext context, String destPath)
template
- 模板context
- 模板上下文destPath
- 目标路径(绝对)public static void toWriter(org.apache.velocity.app.VelocityEngine ve, String templateFileName, org.apache.velocity.VelocityContext context, Writer writer)
ve
- 引擎templateFileName
- 模板文件名context
- 上下文writer
- 流public static void toWriter(String templateFileName, org.apache.velocity.VelocityContext context, Writer writer)
templateFileName
- 模板文件名context
- 上下文writer
- 流public static void toWriter(String templateFileName, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
templateFileName
- 模板文件request
- 请求对象,用于获取模板中的变量值response
- 响应对象public static String merge(String templateContent, org.apache.velocity.VelocityContext context)
templateContent
- 模板的内容字符串context
- 上下文public static void merge(org.apache.velocity.Template template, org.apache.velocity.VelocityContext context, Writer writer)
template
- 模板context
- 内容writer
- Writerpublic static org.apache.velocity.VelocityContext parseRequest(org.apache.velocity.VelocityContext context, javax.servlet.http.HttpServletRequest request)
context
- 内容request
- 请求对象public static org.apache.velocity.VelocityContext parseSession(org.apache.velocity.VelocityContext context, javax.servlet.http.HttpSession session)
context
- 模板上下文session
- SessionCopyright © 2021. All rights reserved.