检查字符串是否为有效的EL表达式(Java)

huangapple 未分类评论48阅读模式
英文:

Check if string is valid EL expression (Java)

问题

我需要检查输入的字符串是否是有效的EL表达式,以便我可以设置它的实际值。可以通过正则表达式或一些现有的Java库/代码来实现。

输入和输出可能如下:

"${prop.key}" ==> true
"${prop.method()}" ==> true
"#{prop.key}" ==> true
"prop.key" ==> false
"${prop key}" ==> false
"{prop.key}" ==> false
英文:

I need to check if input string is a valid EL expression or not, so that I can set it's actual value. It can be done by either regex or some existing java library/code.

Input and Output could be like:

"${prop.key}" ==> true
"${prop.method()}" ==> true
"#{prop.key}" ==> true
"prop.key" ==> false
"${prop key}" ==> false
"{prop.key}" ==> false

答案1

得分: 0

如果您想验证和/或评估表达式,请使用 EL 解析器,例如 JUEL

英文:

If you want to validate and/or evaluate the expression, use an EL parser, e.g. JUEL.

huangapple
  • 本文由 发表于 2020年4月10日 12:14:25
  • 转载请务必保留本文链接:https://java.coder-hub.com/61133944.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定