English 中文(简体)
贴上标签,从Label Valuebean获得价值
原标题:match the label and get value from Labelvaluebean
  • 时间:2011-02-18 00:08:19
  •  标签:
  • java

I m getting a list of organization type and code are stored as labelvaluebean as below: [LabelValueBean[ORG1, XX], [ORG2, AA]] - in array.

later these values are stored in a session variable. My question is, is there a way I can search thru this array to match the name and get the code ? (for ex: match with ORG1 and get XX). If user enter ORG1, I should send XX to back-end.

问题回答

您希望使用Map,而不是一个阵列。 缩略语 然后,在您找到对等之前,请在您的头一栏中看一面的数值,然后看一下该代码第二栏,然后回去。 显然,这由<代码>Map执行处理,因此,你们都需要宣布什么为<代码>。 物体/代码应作为关键和价值使用。 如果是的话,你可能会有<代码>Map<String, String>。

例如,

Map<String, String> map = new HashMap<String, String>();
map.put("ORG1", "XX");
map.put("ORG2", "AA");
map.get("ORG1") // returns "XX"
map.get("ORG2") // returns "AA"




相关问题
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 ...

热门标签