这是我用来重新填充ArrayList
<form method = "POST" action = "addItemsToTemplate">
<s:iterator value = "myQuestions" var = "quizItem" status="key">
<s:textfield name = "quizItem.question"/>
</s:iterator>
<input type = "submit" value = "submit"/>
</form>
这是动作类
public class QuizTest extends ActionSupport{
public String execute(){
List<Question> q= myQuestions;
System.out.println(myQuestions);
return "success";
}
public String populateQuestions(){
//more code here
}
public void setMyQuestions(List<Question> myQuestions) {
this.myQuestions = myQuestions;
}
private List<Question> myQuestions = new ArrayList<Question>();
}
myQuestions
问题对象列表在哪里。提交后,这给了我一个错误
Unexpected Exception caught setting 'quizItem.question' on 'class quiz.actions.QuizTemplateAction: Error setting expression 'quizItem.question' with value '[Ljava.lang.String;@1b3409f'
并System.out.println(myQuestions);
打印一个空列表。但是在提交表单之前,myQuestions
已经通过这种方法从另一个填充 了populateQuestions()