Java Struts 1.3遍历动态问题列表
如有任何帮助,将不胜感激: 在我的JSP中,我有一个动态问题列表,每个问题都有一个输入字段,如下所示:Java Struts 1.3遍历动态问题列表,java,jsp,struts,javabeans,Java,Jsp,Struts,Javabeans,如有任何帮助,将不胜感激: 在我的JSP中,我有一个动态问题列表,每个问题都有一个输入字段,如下所示: <logic:iterate name="listOfQuestions" id="listOfQuestionsId" indexId="indexId"> <tr> <td align="right" width="100%"><bean:message key='<%= "prompt.questio
<logic:iterate name="listOfQuestions" id="listOfQuestionsId" indexId="indexId">
<tr>
<td align="right" width="100%"><bean:message key='<%= "prompt.question" + (indexId.intValue() +1)%>'/>: </td><td width="100%" nowrap="nowrap"><bean:write name="listOfQuestionsId"/></td>
</tr>
<tr align="center">
<td align="right" width="50%"><bean:message key="prompt.answer"/>: </td>
<td align="left" width="50%"><html:password property="questions" size="30" maxlength="40" indexed="true"></html:password></td>
</tr>
</logic:iterate>
您希望您的questions属性如何从jsp/视图呈现为
列表问题
?您是否尝试过调试validateQuestionsForm
?如果是,请检查您的问题属性。您只需将列表属性更改为字符串数组
。就像你的多重方程形式一样
private String[] questions;
和此属性的getter setter。现在您可以接收字符串数组并对其进行迭代。希望这有帮助
//Use the ValidateInfoForm to get the request parameters
MultipleQuestionsForm validateQuestionsForm = (MultipleQuestionsForm) form;
List<String> listOfquestions = validateQuestionsForm.getQuestions();
for(String s: listOfquestions) System.out.println(s); //nullPointer since getQuestions() doesn't return the input values
private String[] questions;