小编pab*_*l0x的帖子

如何使用Struts Form管理多维数组

我正在使用Apache Struts 1.3来渲染网格,这是一个嵌入.jsp的html表单.就像是

<html:form action="/MyController.do?action=processForm">
<html:text property="taxation[0][0]" value="" styleClass="gridInputs"></html:text>
<html:text property="taxation[0][1]" value="" styleClass="gridInputs"></html:text>
 ...
<html:text property="taxation[10][10]" value="" styleClass="gridInputs"></html:text>
Run Code Online (Sandbox Code Playgroud)

MyController与ActionForm相关联:

public class MyForm extends ActionForm{

protected String taxation[][]= new String [10][10]; 

public String[] getTaxation() {
    return taxation;
}

public void setTaxation(String[][] taxation) {
    this.taxation = taxation;
}
Run Code Online (Sandbox Code Playgroud)

当我尝试检索表单提交的信息时出现问题.Whithin MyController.class我有一个简单的调度程序操作

public class MyController extends DispatchAction {
public ActionForward processForm(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) {

    MyForm myform = (MyForm) form;

            // Here i can use the getter method to retrieve …
Run Code Online (Sandbox Code Playgroud)

java web-applications struts-1

5
推荐指数
1
解决办法
4528
查看次数

标签 统计

java ×1

struts-1 ×1

web-applications ×1