java - Set value into variable in struts1 -
i can iterate list in struts1 using below code :
<logic:iterate name="listmsg" id="listmsgid"> <p> list messages <bean:write name="listmsgid"/> </p> </logic:iterate>
but how can set variable within tag.
for example want fetch data above tag , initialize in variable.
<logic:iterate name="listmsg" id="listmsgid"> <p> <% string firstname = "get data list"; %> list messages <bean:write name="listmsgid"/> </p> </logic:iterate>
how can achieve above 1 using struts1 , java.
is possible? if yes how?
one solution, , imo better one, use jsp jstl. see example below:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%--@elvariable id="messages" type="java.util.list"--%> <c:foreach items="${messages.msglist}" var="message" varstatus="st"> <c:set var="varname" value="varvalue"/> <p>${message.id}</p> <p>${varname}</p> <!-- print --> </c:foreach>
hope helps!
Comments
Post a Comment