enjoy 3.4
This commit is contained in:
@@ -32,7 +32,7 @@ import com.jfinal.template.stat.Scope;
|
||||
*/
|
||||
public class NowDirective extends Directive {
|
||||
|
||||
public void setExrpList(ExprList exprList) {
|
||||
public void setExprList(ExprList exprList) {
|
||||
if (exprList.length() > 1) {
|
||||
throw new ParseException("#now directive support one parameter only", location);
|
||||
}
|
||||
|
@@ -16,22 +16,29 @@
|
||||
|
||||
package com.jfinal.template.ext.directive;
|
||||
|
||||
import java.io.IOException;
|
||||
import com.jfinal.template.Directive;
|
||||
import com.jfinal.template.Env;
|
||||
import com.jfinal.template.TemplateException;
|
||||
import com.jfinal.template.io.Writer;
|
||||
import com.jfinal.template.stat.Scope;
|
||||
|
||||
/**
|
||||
* 输出随机数
|
||||
* 输出 int 型随机数
|
||||
*/
|
||||
public class RandomDirective extends Directive {
|
||||
|
||||
private java.util.Random random = new java.util.Random();
|
||||
|
||||
public void exec(Env env, Scope scope, Writer writer) {
|
||||
write(writer, String.valueOf(random.nextInt()));
|
||||
try {
|
||||
writer.write(random.nextInt());
|
||||
} catch (IOException e) {
|
||||
throw new TemplateException(e.getMessage(), location, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user