Techniques of EL on Java

2019-08-08 21:59发布

I interest in creating my own service for some EL language for POJO. For example, I have some object structure with inner POJO objects, A and B for example. So, I want pass to my service string like "a.b.name" and than get this property value.

Are there any utils in java reflection api or 3rd part libraries?

I can parse this string by myself and then get fields and methods, but I think this is common feature. Any ideas?

3条回答
乱世女痞
2楼-- · 2019-08-08 22:23

Maybe you should look at the Spring Expression language or Groovy.

Spring EL is a full featured expression language (you should be able to use it without using the rest of the framework).

Groovy is a JVM language that can be easily integrated into java applications and it powerfull syntax can be very useful for such tasks. Since its compatible to Java you can access and modify your Java objects from groovy code.

You can also look at Jexl. I haven't used this one so far but it looks useful for your task.

查看更多
迷人小祖宗
3楼-- · 2019-08-08 22:40

Here are some more options that are available:

查看更多
聊天终结者
4楼-- · 2019-08-08 22:40

I used MVEL

It really reduced the code.

查看更多
登录 后发表回答