How to get updated list values from JSP in my action?

后端 未结 1 1121
北恋
北恋 2020-12-18 16:36

I have a JSP in which I am iterating over a list and creating an editable table.


  
    

        
相关标签:
1条回答
  • 2020-12-18 17:18

    You need the Country object is created when the params interceptor is populating your list using indexed property access.

    <s:iterator value="test" id="countryList" status="stat">
      <tr>
        <td><s:textfield name="countryList[%{#stat.index}].countryCode" value="%{countryCode}" theme="simple" /></td>
        <td><s:textfield name="countryList[%{#stat.index}].countryName" value="%{countryName}" theme="simple" /></td>
      </tr>
     </s:iterator>
    

    To let the struts populate the list you should use a type conversion annotation or equivalent in the xml configuration.

    @Element(value = Country.class)
    @Key(value = String.class)
    @KeyProperty(value = "countryCode") 
    @CreateIfNull(value = true)
    private List<Country> countryList = new ArrayList<Country>;
    
    0 讨论(0)
提交回复
热议问题