springboot获取html的数据库,在Springboot中从数据库获取velocity模板

我必须从Spring引导和Spring数据项目中的数据库中获取velocity模板。我还没有尝试过任何代码,因为我对所有技术(Velocity,Spring启动和数据)都是新手而不是在google上找到任何东西。有没有人试图从db获取模板,请给我建议一些链接或其他我可以参考的内容?在Springboot中从数据库获取velocity模板

更新:我在分贝绑定类(Grails中),我有从Java访问过程。在方法DB类是, 类bindingSubject {

DEF登录

DEF过程= {酒馆,listForMail - >

def mapBinding = [:]

def fund

def perimeters = pub.sub.entities

perimeters.each(){ entity ->

if (fu == null){

if (entity instanceof S)

fu = entity.fu

if (entity instanceof Fund)

fu = fu

}

}mapBinding.entity = fu.name return mapBinding

}

} 和Java代码写入到

- >加载脚本

mapScriptClass = new HashMap();

if (script != null) {

if (mapScriptClass.get(name) == null) {

GroovyCodeSource groovySource = new GroovyCodeSource(script,name,"");

GroovyClassLoader classLoader = new GroovyClassLoader(this.getClass().getClassLoader());

// Load string as Groovy script class.

Class scriptClass = classLoader.parseClass(groovySource);

try {

Object classInstance = scriptClass.newInstance();

ApplicationContext ctx = (ApplicationContext)ServletContextHolder

.getServletContext().getAttribute(ApplicationAttributes.APPLICATION_CONTEXT);

ctx.getAutowireCapableBeanFactory().autowireBeanProperties(classInstance, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false);

mapScriptClass.put(name, classInstance);

return classInstance;

拨叫分贝过程方法(在Grails的工作原理,如何做到这一点在Java中?)

Object scriptClass = loadScriptService.getScriptClass("scriptBindingSubject"+templateMail.getId(),

templateMail.getScriptBindingSubject());

if (scriptClass != null) {

try{

bindingSubject = scriptClass.process(pub,subMail);

}

现在我不知道如何调用过程方法从Java(至DB)绑定属性

谢谢。

2016-09-21

Khushi

+0

有示例示例https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-web-velocity –

+0

为什么你想存储我们的数据库中的模板?我会更简单,如果他们直接捆绑在您的应用程序 –

+0

嗨,安迪,其实它的一个Grails项目,其中模板以html格式保存在分贝,现在我必须访问一些模板在Java应用程序,在Grails SimpleTemplateEngine正在与GroovyClassLoader一起使用来绑定变量,所以在java中我必须使用类似的东西,除了速度可以与GroovyClassLoader平滑对话之外,还有其他替代品吗? –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值