| 程序包 | 说明 |
|---|---|
| com.jfinal.kit | |
| com.jfinal.template | |
| com.jfinal.template.ext.spring |
| 限定符和类型 | 方法和说明 |
|---|---|
static Engine |
ElKit.getEngine() |
| 限定符和类型 | 方法和说明 |
|---|---|
Engine |
Engine.addDirective(String directiveName,
Class<? extends Directive> directiveClass)
Add directive
示例:
addDirective("now", NowDirective.class)
|
Engine |
Engine.addDirective(String directiveName,
Directive directive)
已过时。
|
Engine |
Engine.addSharedFunction(ISource source)
Add shared function by ISource
|
Engine |
Engine.addSharedFunction(String... fileNames)
Add shared function by files
|
Engine |
Engine.addSharedFunction(String fileName)
Add shared function by file
|
Engine |
Engine.addSharedFunctionByString(String content)
Add shared function by string content
|
Engine |
Engine.addSharedMethod(Class<?> sharedMethodFromClass)
Add shared method from class
|
Engine |
Engine.addSharedMethod(Object sharedMethodFromObject)
Add shared method from object
|
Engine |
Engine.addSharedObject(String name,
Object object)
Add shared object
|
Engine |
Engine.addSharedStaticMethod(Class<?> sharedStaticMethodFromClass)
Add shared static method of Class
|
static Engine |
Engine.create(String engineName)
Create engine with engine name managed by JFinal
|
static Engine |
Engine.remove(String engineName)
Remove engine with engine name managed by JFinal
|
Engine |
Engine.removeDirective(String directiveName)
Remove directive
|
Engine |
Engine.removeSharedMethod(Class<?> clazz)
Remove shared Method of the Class
|
Engine |
Engine.removeSharedMethod(Method method)
Remove shared Method
|
Engine |
Engine.removeSharedMethod(String methodName)
Remove shared Method by method name
|
Engine |
Engine.removeSharedObject(String name) |
Engine |
Engine.setBaseTemplatePath(String baseTemplatePath) |
Engine |
Engine.setDatePattern(String datePattern) |
Engine |
Engine.setDevMode(boolean devMode)
设置 true 为开发模式,支持模板文件热加载
设置 false 为生产模式,不支持模板文件热加载,以达到更高的性能
|
Engine |
Engine.setEncoderFactory(EncoderFactory encoderFactory)
Enjoy 模板引擎对 UTF-8 的 encoding 做过性能优化,某些偏门字符在
被编码为 UTF-8 时会出现异常,此时可以通过继承扩展 EncoderFactory
来解决编码异常,具体用法参考:
http://www.jfinal.com/feedback/5340
|
Engine |
Engine.setEncoding(String encoding) |
Engine |
Engine.setOutputDirectiveFactory(OutputDirectiveFactory outputDirectiveFactory)
Set output directive factory
|
Engine |
Engine.setReloadModifiedSharedFunctionInDevMode(boolean reloadModifiedSharedFunctionInDevMode)
Engine 独立设置为 devMode 可以方便模板文件在修改后立即生效,
但如果在 devMode 之下并不希望对 addSharedFunction(...),
添加的模板进行是否被修改的检测可以通过此方法设置 false 参进去
注意:Engine 在生产环境下(devMode 为 false),该参数无效
|
Engine |
Engine.setSourceFactory(ISourceFactory sourceFactory)
设置 ISourceFactory 用于为 engine 切换不同的 ISource 实现类
ISource 用于从不同的来源加载模板内容
配置为 ClassPathSourceFactory 时特别注意:
由于 JFinal 会在 configEngine(Engine me) 方法调用 “之前”,会默认调用一次如下方法:
me.setBaseTemplatePath(PathKit.getWebRootPath())
而 ClassPathSourceFactory 在以上默认值下不能工作,所以需要通过如下方式清掉该值:
me.setBaseTemplatePath(null)
或者配置具体要用的 baseTemplatePath 值,例如:
me.setBaseTemplatePath("view");
|
Engine |
Engine.setToClassPathSourceFactory()
设置为 ClassPathSourceFactory 的快捷方法
|
Engine |
Engine.setWriterBufferSize(int bufferSize) |
static Engine |
Engine.use()
Using the main Engine
|
static Engine |
Engine.use(String engineName)
Using the engine with engine name
|
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
Engine.setMainEngine(Engine engine)
Set main engine
|
| 限定符和类型 | 字段和说明 |
|---|---|
static Engine |
JFinalViewResolver.engine |
| 限定符和类型 | 方法和说明 |
|---|---|
Engine |
JFinalViewResolver.getEngine() |
Copyright © 2019. All rights reserved.