Action中定义一个List 里面放了十个对象。
public class testAction extends ActionSupport{
public List<User> testList= new ArrayList<User>();
public String execute(){
for(int i = 0;i<10;i++){
testList.add(new User());
}
return "SUCCESS";
} public List<User> getTestList() {
return testList;
} public void setTestList(List<User> testList) {
this.testList = testList;
}
}
jsp中定义一个表格,想将textfield 于Action中的List绑定。当页面输入值时提交表单后在后台Action中可以接收到一个有值(界面输入的值)的List。但是jsp中像这样写:[name = "info.login"]不能绑定到list中请教应该怎么写。
<table class="Checkbox_table_2">
<tr>
<td >Name</td>
<td>Password</td>
</tr>
<s:iterator value = "testList" id = "info">
<tr>
<td><s:textfield name = "info.login"></s:textfield ></td>
<td><s:textfield name = "info.password"></s:textfield ></td>
</tr>
</s:iterator>
</table>
界面点OK希望后台Action的List可以获取输入的值
public class testAction extends ActionSupport{
public List<User> testList= new ArrayList<User>();
public String execute(){
for(int i = 0;i<10;i++){
testList.add(new User());
}
return "SUCCESS";
} public List<User> getTestList() {
return testList;
} public void setTestList(List<User> testList) {
this.testList = testList;
}
}
jsp中定义一个表格,想将textfield 于Action中的List绑定。当页面输入值时提交表单后在后台Action中可以接收到一个有值(界面输入的值)的List。但是jsp中像这样写:[name = "info.login"]不能绑定到list中请教应该怎么写。
<table class="Checkbox_table_2">
<tr>
<td >Name</td>
<td>Password</td>
</tr>
<s:iterator value = "testList" id = "info">
<tr>
<td><s:textfield name = "info.login"></s:textfield ></td>
<td><s:textfield name = "info.password"></s:textfield ></td>
</tr>
</s:iterator>
</table>
界面点OK希望后台Action的List可以获取输入的值
解决方案 »
- hibernate问题, HibernateUtils下怎么画波浪线的啊
- jsp新手求助
- 谁有j2ee比较全的视频呀
- 新手请教java中异常要什么看!
- ext未定义
- dao中的bean与struts中的actionForm的疑问
- Hibernate不支持Oracle的clob类型吗?
- 关于struts的问题!请各位高手帮忙!
- 急:java中想把xml文档传给一个servlet,就是实现微软的XMLHTTP,能用流传吗,如何做请教
- spring ehcache手动或定时刷新缓存,如何实现?
- eclipse 导入 hibernate自带的project出现问题
- Hibernate反向生成MySQL数据库的时候,居然出了字段太长的问题
这种情况可以将数据转成json格式(jquery有现成的方法) 后台用string接收 然后转成list(可以用gson)
<s:textfield name = "login">${info.login}</s:textfield >
别的类似
<tr>
<td><s:textfield name = "testList[#st.index].name"></s:textfield></td>
<td><s:textfield name = "testList[#st.index].password"></s:textfield ></td>
</tr>
</s:iterator>
<tr>
<td >Name</td>
<td>Password</td>
</tr>
<s:iterator value = "testList" var = "info">
<tr>
<td><s:textfield name = "#info.login"></s:textfield ></td>
<td><s:textfield name = "#info.password"></s:textfield ></td>
</tr>
</s:iterator>
</table>怎么能是id呢,应该是var = "info"