arraylist.add(new ListItem("Activity1", "ActivityName1"));
suppose Activit开发者_如何转开发yName1 value store in properties file to provide locale feature.
now how can i access the value of Activity1 key that associate to ActivityName1 value on jsp ( ActivityName1 corresponds to a properties file value) by using Struts.
i want to find the ActivityName1 value that store in properties file by using the Activity1 key in Struts framework.
For example if your struts property file defined as follows,
ActivityName1=Activity Name 1 Value in English
inside the JSP file simply you can access it as follows,
<s:label value="%{getText('ActivityName1')}"/>
And to iterate through your ArrayList in the JSP file you can use the tag. And following is an simple example,
ListItem bean class
public class ListItem {
private String listKey;
private String listValue;
// getters and setters
}
Inside Action class
// defined in action calss with getters and setters
private List<ListItem> listItems;
// inside method in action class
listItems.add(new ListItem("Activity1","ActivityName1"));
......
inside JSP file
<s:iterator value="listItems">
<s:property value="%{getText('listKey')}"/>
<s:property value="%{getText('listValue')}"/>
</s:iterator>
By combining these tips I think you will find a solution for your question....
Try to Use hashmap..And add that map to the array list..Use
精彩评论