Repopulate ArrayList from JSP with Struts 2

后端 未结 3 1884
抹茶落季
抹茶落季 2020-12-04 03:24

This is the form I am using to repopulate the ArrayList

3条回答
  •  甜味超标
    2020-12-04 04:10

        Where myQuestions is a List of Question Objects. 
        upon submission this gives me an error
    

    Since it is a list of Questions Objects you are trying to populate a Question Object with a String. Please check if you have the converter defined to covert String into Question and also specified in the xwork-conversion.properties file

    System.out.println(myQuestions); prints an empty list.
    

    instead of doing this

    private List myQuestions = new ArrayList();
    

    do this

    private List myQuestions;
    

    When you are submiting the form, a new object of your Action class is created and your instance variable "myQuestions" gets reinitialized with each submission.

    Hope this helps :)

提交回复
热议问题