Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Struts 1.3遍历动态问题列表_Java_Jsp_Struts_Javabeans - Fatal编程技术网

Java Struts 1.3遍历动态问题列表

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

如有任何帮助,将不胜感激:

在我的JSP中,我有一个动态问题列表,每个问题都有一个输入字段,如下所示:

<logic:iterate name="listOfQuestions" id="listOfQuestionsId" indexId="indexId">
        <tr>
            <td align="right" width="100%"><bean:message key='<%= "prompt.question" + (indexId.intValue() +1)%>'/>:&nbsp;&nbsp;</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"/>:&nbsp;&nbsp;</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;