I need to load a dropdown list from properties, and that drop down should be dynamic (We can add more values to that property file)
I am using struts1.x
I have done by the form that goes to action class and grabbing those from property files and setting in form, Instead of this way I need without going to action.
You can use
html:messages
tag.
<html:messages id="msg" bundle="Property_file">
<li><bean:write name="msg" /></li>
</html:messages>
Example can be found here
I tried this and this worked or similar/for reference you can use this
<%@ page language="java" import="java.util.*" %>
<h1 align="center" > </h1>
<%
ResourceBundle messages =ResourceBundle.getBundle("messages");
Enumeration messageKeys = messages.getKeys();
%>
<table align="center" >
<tr>
<td> Select User:</td>
<td>
<select name="user" >
<%
while(messageKeys.hasMoreElements()){
String key = (String)messageKeys.nextElement();
String value = messages.getString(key);
%>
<option value="<%=messages.getString(key)%>">
<%=messages.getString(key)%>
</option>
<%
}
%>
</select>
</td>
</tr>
</table>
And using tag, i am using following tag with corresponding key for just accessing it in jsp page,
<%@ taglib uri="/WEB-INF/taglibs/struts-bean.tld" prefix="bean" %>
<bean:message bundle="bundle_name" key="your_key"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.