我正在使用struts2框架。我有一個操作,在一些處理後轉發給結果JSP。 該動作的形式包含一個數組對象及其設置者和獲取者。 我也使用模型驅動接口,以便所有表單域自動映射。 現在,在結果JSP中,我想將該數組對象設置在隱藏字段中,以便在表單上再次提交該數組對象時被映射,但發生了什麼(讓我的數組元素爲{1,2,3})隱藏字段標記將此數組轉換爲「1,2,3」的String對象,並將其設置爲數組對象的第一個元素。我應該怎麼做?在struts2隱藏字段中設置數組對象
<s:iterator value="licenseType" status="stat1">
<s:hidden name="licenseType[%{#stat1.index}]" />
</s:iterator>
<s:iterator value="status" status="stat2">
<s:hidden name="status[%{#stat2.index}]" />
</s:iterator>
Action類越來越形態價值--- >>
int i=0;
String h[]=activeLicenseReportForm.getLicenseType();
String license ="";
for(i=0; i<h.length; i++)
setter和getter表格----- >>>
public String[] getLicenseType() {
return _licenseType;
}
public void setLicenseType(String[]licenseType) {
this._licenseType=licenseType;
}
一個字段 - >一個值。如果你只想使用struts標籤來做到這一點,你需要遍歷你的數組,併爲數組中的each_ item設置一個隱藏字段。如果所有這些字段具有相同的名稱,那麼表單將爲同一個變量發送多個值 - 一個數組。 –