|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectcom.xiaoleilu.hutool.VelocityUtil
public class VelocityUtil
Velocity模板引擎工具类
使用前必须初始化工具类
| 构造方法摘要 | |
|---|---|
VelocityUtil()
|
|
| 方法摘要 | |
|---|---|
static String |
getContent(String templateDir,
String templateFileName,
org.apache.velocity.VelocityContext context,
String charset)
获得指定模板填充后的内容 |
static String |
getContent(String templateFileName,
org.apache.velocity.VelocityContext context)
获得指定模板填充后的内容,使用默认引擎 |
static String |
getContent(org.apache.velocity.app.VelocityEngine ve,
String templateFileName,
org.apache.velocity.VelocityContext context)
获得指定模板填充后的内容 |
static void |
init(String templateDir,
String charset)
初始化Velocity全局属性 |
static String |
merge(String templateContent,
org.apache.velocity.VelocityContext context)
融合模板和内容 |
static org.apache.velocity.app.VelocityEngine |
newEngine(String templateDir,
String charset)
新建Velocity模板引擎 |
static org.apache.velocity.VelocityContext |
parseRequest(javax.servlet.http.HttpServletRequest request)
将Request中的数据转换为模板引擎 |
static void |
toFile(String templateFileName,
org.apache.velocity.VelocityContext context,
String destPath)
生成文件,使用默认引擎 |
static void |
toFile(org.apache.velocity.Template template,
org.apache.velocity.VelocityContext context,
String destPath)
生成文件 |
static void |
toFile(org.apache.velocity.app.VelocityEngine ve,
String templateFileName,
org.apache.velocity.VelocityContext context,
String destPath)
生成文件 |
static void |
toWriter(String templateFileName,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
生成内容写到响应内容中 模板的变量来自于Request的Attribute对象 |
static void |
toWriter(String templateFileName,
org.apache.velocity.VelocityContext context,
Writer writer)
生成内容写入流 会自动关闭Writer |
static void |
toWriter(org.apache.velocity.app.VelocityEngine ve,
String templateFileName,
org.apache.velocity.VelocityContext context,
Writer writer)
生成内容写入流 会自动关闭Writer |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 构造方法详细信息 |
|---|
public VelocityUtil()
| 方法详细信息 |
|---|
public static void init(String templateDir,
String charset)
templateDir - 模板所在目录,绝对路径
public static org.apache.velocity.app.VelocityEngine newEngine(String templateDir,
String charset)
templateDir - 模板所在目录,绝对路径
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 String merge(String templateContent,
org.apache.velocity.VelocityContext context)
templateContent - 模板的内容字符串context - 上下文
public static void toWriter(String templateFileName,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
templateFileName - 模板文件request - 请求对象,用于获取模板中的变量值response - 响应对象public static org.apache.velocity.VelocityContext parseRequest(javax.servlet.http.HttpServletRequest request)
request - 请求对象
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||