Techniques of EL on Java

…衆ロ難τιáo~ 提交于 2019-12-13 02:08:40

问题


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?


回答1:


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.




回答2:


Here are some more options that are available:

  • OGNL
  • MVEL
  • Velocity



回答3:


I used MVEL

It really reduced the code.



来源:https://stackoverflow.com/questions/13940294/techniques-of-el-on-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!