0
我对Spring的注释和JSTL相当陌生。如何将varStatus计数从JSP传递到控制器?
我试图从JSP向Spring Controller传递索引计数的值。但是,我不知道我该怎么做。我无法将此计数设置为路径变量或请求参数。 JSP中有没有将模型中的属性设置为特定值的方法?
示例代码(来自here)
...
<form:form modelAttribute="${questionForm}" ... >
<%-- render HTML for your question, etc. --%>
${questionForm.question}
...
</p>
<%-- below list your answer fields (your collection) --%>
<c:forEach var="answer" items="${questionForm.answers}" varStatus="counter">
<%-- display your single answer field (text area) here,
each element of your list may be accessed as ${answer},
and you can also access the index of the element in the list via ${counter.index} --%>
</c:forEach>
... other fields, submit buttons, etc.
</form:form>
...
在这个例子中我可以设置${counter.index}
到一个属性在模型{questionForm}
?