gpt4 book ai didi

Java 表达式语言 : Interpolation?

转载 作者:行者123 更新时间:2023-11-30 06:38:34 24 4
gpt4 key购买 nike

问候,

在我正在开发的网络应用程序中,我想做如下事情:

我有一个 bean

class Gene{
String geneid;
String sequence;
..
}

// EL expression (sometimes should be simple as "${geneid}" without URL pattern)
String exp="<a> href='http://www.ncbi.nlm.nih.gov/pubmed?term=${geneid}' />";
String outputString=someframeworkobject.somemethod(exp,aGeneInstance);

因此 outputString 的插值如下:http://www.ncbi.nlm.nih.gov/pubmed?term=gene19191X

有没有我可以使用的轻量级 EL 框架?

最佳答案

也许 MVEL会为你工作。

像这样的模板

 Hello, @{person.getSex() == 'F' ? 'Ms.' : 'Mr.'} @{person.name}

你可以做到

 context.put("person", personBean);
String output = (String) TemplateRuntime.eval(template, context);

查看 this tutorial (我在哪里读到这个,我没有使用 MVEL 的经验)。

关于Java 表达式语言 : Interpolation?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2098839/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com