English 中文(简体)
如何在地图中从列表中获取元素元素?
原标题:How to use PropertyUtils to get an element from a list inside a map?

我一直在尝试使用索引化的标记来获取属性属性工具的属性, 以检索作为地图值的列表中的元素。 这里举一个例子( 我在这里使用通用语法 ) :

map = {"aList": ["elem1", "elem2", "elem3"]}

不如说,我想得到"Elem2"的值, 我想用:

PropertyUtils.getProperty(map, "aList[1]");

但它似乎不起作用。 我总是得到一个无效值。 是否有其他方法可以做到这一点。 为了清楚起见, 我知道我可以做一个 < code> getProperty ("aList").get(0) (在明确铸造后), 当然) 但我正在研究一个需要上述代码才能起作用的解决方案 。

最佳回答

好吧,我明白了,下面的代码就像我想要的一样

PropertyUtils.getProperty(map, "(aList)[1]");

我认为,基于"https://commons.apache.org/proper/commons-beanutils/apidocs/org/apache/commons/beanutils/PropertyUtilsBean.html" rel=“nofollow”>此文档 ,我在这里所做的是具体说明aList 是豆的钥匙而不是索引属性。类似的东西。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签