jsp attribute value-trying to use expressions to form attribute values
I am facing a basic problem in my jsp. I have a jsp. There is a div element that is part of a loop .So here x is a counter. I am trying somethin开发者_StackOverflowg like below but this is not valid syntax.
<% for (int x =0; x <5; x++) { %>
<s:div theme="ajax" id = <%=x%>
<s:form>
<s:submit theme="ajax" targets = '<%=x%>' />
</s:form>
</s:div>
< % } % >
Could you please help? The problem is that id = <%=x%> or targets = '<%=x%>' seems to be invalid syntax. My goal is to have 'id' attribute and 'targets' attribute hold a dynamic value(based on value of counter 'x')
You should close the first s:div and mark the id with quotes : <s:div theme="ajax" id="<%=x%>">
精彩评论