嗨,让我告诉你我搜索了很多,但我找不到我想要的
这是场景
我的jsp中有一个表正在通过迭代器加载,它是ArrayList<Report>
报告具有三个属性参数,观察,设计
在 JSP 中,我将通过迭代器显示第一列和第三列的值
<s:iterator value="ReportList" status="status" var="obj">
<tr>
<td><s:property value="%{#obj.parameter}" /></td>
<td><s:textfield theme="simple" name="valOfSim" /></td>
<td><s:property value="%{#obj.designed}" /></td>
</tr>
</s:iterator>
Parameter observation designed X 10 y 11 Z 12
现在我必须捕获已输入的第二个值,请帮助!
编辑:我的代码
让我解释一下,第一个 preload 方法将被调用,值将被预填充ArrayList<Obj>
,然后用户将输入值进行观察,然后通过这个捕获它
<td><s:textfield theme="simple" name="obj[%{#status.index}].observation" /></td>
之后,将出现一个提交按钮,单击该操作类的提交方法将被调用
打印用户输入的值(这里是 NULL)
import mypro.web.utility.SpringServiceLocator;
public class myAction extends ActionSupport implements
ModelDriven,SessionAware,ServletRequestAware,Preparable {
private Map<String, Object> session;
private Model model = new Model();
public void prepare()
{
Obj obj = new Obj();
Obj obj2 = new Obj();
Obj obj3 = new Obj();
obj.setDesigned("10");
obj.setParameter("X");
model.getReportList().add(obj1);
obj.setDesigned("11");
obj.setParameter("y");
model.getReportList().add(obj2);
obj.setDesigned("12");
obj.setParameter("Z");
model.getReportList().add(obj3);
}
public String preload()
{
return "success";
}
public String submit()
{
System.out.println("------------------------------------------------------
&&&&&&&&&:"+model.getReportList().size());
for(Obj obj : model.getReportList)
{
System.out.println("the value is to be checked"+obj.getObservation());//value which will be entered by user
System.out.println("the value is to be checked"+obj.getRefcode()); //value which was added in the prepare method
}
return "success";
}
public Object getModel() {
return model;
}