java - Accessing an iteration value with JSP -


new jsp, still learning functionality. assume being handed list of values , list being iterated html code being output value of property of current iteration. trying current property , check see if value matches searching, , if does, perform action.

the original .jsp code:

<select name="userinfo.state">     <option class="js_default_option">state</option>     <s:iterator value="@com.homeservices.action.utils.statecode@values()">         <option value='<s:property/>'><s:property/></option>     </s:iterator> </select>  

what want do:

<select name="userinfo.state">     <option class="js_default_option">state</option>     <s:iterator value="@com.homeservices.action.utils.statecode@values()">         <% if(s:property == "value") { %>             <option value='<s:property/>' disabled><s:property/></option>         <% } %>         <option value='<s:property/>'><s:property/></option>     </s:iterator> </select>  

the struts iterator documentation here. can use var attribute hold reference current iterator element.

<s:iterator var="element" value="@com.homeservices.action.utils.statecode@values()"> // i'm not sure whole @... part 

you can use ${element} (or #element in struts' tags) reference each current iteration element.

please don't use scriplets in jsp. use jstl or struts' tag libraries.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -