用户列表页面的增删改查
点击修改后,
//回显
public String edit() throws Exception {
table1 = new Tbtable1();
table1= table1Service.queryTable1ById(tid);
return "edit";
}
----------------------------------------------------------------------
然后跳转到Table1-edit.jsp,回显数据
<s:form action="Table1!update.action" namespace="/">
<s:hidden name="table1.id" />
<!-- <s:textfield label="table1_id" name="table1.id" />-->
<!-- <s:textfield label="field1" name="table1.field1" value="table1.field1"/>
一开始想要使用value的方式没有成功
-->
<s:textfield label="field1" name="table1.field1" />
<s:textfield label="field2" name="table1.field2" />
<s:textfield label="field3" name="table1.field3" />
<s:submit />
</s:form>
[color=red]注意:[/color]在回显数据的时候,
这个table实体应该是从TableAction类的public String edit() 方法查找到的,name="table1.field1",
要显示数据就必须要调用TableAction类的public Tbtable1 getTable1()方法。
而在修改后,提交数据的时候,是往TableAction类的public String update()的方法中提交,也一定会调用
public void setTable1(Tbtable1 table1)方法。
----------------------------------------------------------------------
修改数据后,点击 submit 按钮 然后提交表单到Table1!update.action,进行保存或更新
public String update() throws Exception {
table1Service.saveOrUpdate(table1);
return "delete";
}
---------------------------------------------------------------------
//经过我修改过的显示数据要执行的方法 当没有tid值的时候 显示的时候文本框为空,tid有值就进行回显
public String edit() throws Exception {
table1 = new Tbtable1();
[size=medium] if(tid!=null&&!"".equals(tid))[/size]{
table1= table1Service.queryTable1ById(tid);
}
return "edit";
}
[color=red][size=x-large]两个不等于中间用&&连接,然后 不等于空是tid!=null
而不等于空字符串是!"".equals(tid)[/size][/color]
点击修改后,
//回显
public String edit() throws Exception {
table1 = new Tbtable1();
table1= table1Service.queryTable1ById(tid);
return "edit";
}
----------------------------------------------------------------------
然后跳转到Table1-edit.jsp,回显数据
<s:form action="Table1!update.action" namespace="/">
<s:hidden name="table1.id" />
<!-- <s:textfield label="table1_id" name="table1.id" />-->
<!-- <s:textfield label="field1" name="table1.field1" value="table1.field1"/>
一开始想要使用value的方式没有成功
-->
<s:textfield label="field1" name="table1.field1" />
<s:textfield label="field2" name="table1.field2" />
<s:textfield label="field3" name="table1.field3" />
<s:submit />
</s:form>
[color=red]注意:[/color]在回显数据的时候,
这个table实体应该是从TableAction类的public String edit() 方法查找到的,name="table1.field1",
要显示数据就必须要调用TableAction类的public Tbtable1 getTable1()方法。
而在修改后,提交数据的时候,是往TableAction类的public String update()的方法中提交,也一定会调用
public void setTable1(Tbtable1 table1)方法。
----------------------------------------------------------------------
修改数据后,点击 submit 按钮 然后提交表单到Table1!update.action,进行保存或更新
public String update() throws Exception {
table1Service.saveOrUpdate(table1);
return "delete";
}
---------------------------------------------------------------------
//经过我修改过的显示数据要执行的方法 当没有tid值的时候 显示的时候文本框为空,tid有值就进行回显
public String edit() throws Exception {
table1 = new Tbtable1();
[size=medium] if(tid!=null&&!"".equals(tid))[/size]{
table1= table1Service.queryTable1ById(tid);
}
return "edit";
}
[color=red][size=x-large]两个不等于中间用&&连接,然后 不等于空是tid!=null
而不等于空字符串是!"".equals(tid)[/size][/color]