在Struts 2中,值没有从jsp绑定到action类
我正在研究Struts2 Web应用程序,目前我正面临着表单绑定的问题。 从jsp到action类的绑定不起作用。
方案是我有一个从上一个操作设置的列表。 在当前的jsp中,我迭代列表并在jsp中打印表中的值。 由于要求,我应该使字段可编辑,以便用户可以编辑显示的值并将更新的值提交给下一个操作。
问题是我从jsp编辑的值没有绑定到action类中的列表。 我尝试了多种方法,但直到现在还没有运气。 以下是我尝试过的方式。
我试过值的第一种方式没有受到约束:
<tr onclick="SelIndex('');"> <input type="text" size = "8" value=""/> <input type="text" size = "8" class="dateFilter" value=""/> <input type="text" size = "8" value=""/> <input type="text" size = "10" value=""/> </s:iterator
第二种方式我尝试了不受约束的价值观:
<tr onclick="SelIndex('');"> <input type="text" name="list1[%{#rowStatus.index}].pln_n_n" value=""/> <input type="text" size = "8" name="list1[%{#rowStatus.index}].trd_d" class="dateFilter" value=""/> <input type="text" name="list1[%{#rowStatus.index}].description" size = "8" value=""/> <input type="text" name="list1[%{#rowStatus.index}].price" size = "10" value=""/>
下面是我的动作类
public class testAction extends BaseAction { private List list1 = null; // getters and setters for list1 public String ListPage() throws AppException { String strReturn = "SUCCESS"; // This the method from which the list1 is populated } public String ListPageSave() throws AppException { String strReturn = "SUCCESS"; // This the method where i need the updated values from list1 // values are not getting bound when this method is called from the page which is having Iterator tag, }
}
BaseAction: public class BaseAction extends ActionSupport implements SessionAware, ServletRequestAware, ServletResponseAware, ServletContextAware { /** * */ private static final long serialVersionUID = 1L; /** * HTTP Request object.
ProcessVO
包含每个属性的属性和getter以及setter。
谁能告诉我这里的问题。 我正在使用需要更新的相同list1对象。 任何帮助对我都非常有用,因为我遇到了这个问题。
"/>
如果您使用HTML标记,OGNL将无法在其中使用。
您需要使用
:
].pln_n_n" value = " "/>
或使用Struts2标签,其中OGNL的工作原理:
附注:
- 如果它与
name
没有区别,则不需要value
-
"SUCCESS"
是违反惯例的,应该是"success"
(由SUCCESS
常量映射)