使用Beetl实现静态页生成
使用Beetl 1.1实现静态页的生成。
使用struts1.2
首先在Lisener中设置ServletGroupTemplate相关配置。
模版文件位于WEB-INF/template下
模版文件:index.html
web.xml中的配置
由于要对显示的字符串进行截取,定义了两个函数:
感觉自定义函数功能不错,但是也麻烦了些,两个函数就要写两个类。
如果能归类就好了,比如对字符串的操作,一个自定义函数中不同的方法就可以搞定。 }
public string substring(String str,int,int,Context ctx){........}
public int lenght(String str,Context ctx){...........}
}
然后,GroupTemplate.registerFunctionPackage(new myStringsFunction() )
这样,就可以在模板里使用
${mycom.string.substring("abcddd",1,4)}
你觉得怎么样? }
public string substring(String str,int,int,Context ctx){........}
public int lenght(String str,Context ctx){...........}
}
然后,GroupTemplate.registerFunctionPackage(new myStringsFunction() )
这样,就可以在模板里使用
${mycom.string.substring("abcddd",1,4)}
你觉得怎么样?
这样不错