public class Emp implements java.io.Serializable
{
private String name;
private String sex;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
}
public class EmpForm extends ActionForm{
private List empList = new ArrayList();
public List getEmpList(){return this.empList;}
public void setEmpList(List empList)
{
this.empList = empList;
}
}
public class EmpAction extends Action
{
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
EmpForm empForm = (EmpForm) form;
if ("list".equals(empForm.getType())){
empFrom.setEmpList(EmpService.allEmp());//从数据库中取出
return mapping.findForward("list");
}
else{
EmpService.saveEmp(empForm.getEmpList());
rerturn mapping.findForward("save");
}
}
}
从数据库中取出Emp对象显示在页面上像这样
姓名 性别 年龄 添加
张三 男 20
李四 男 21
....
保存
点添加按钮时用javascript动态生成一行,文本框,下拉框,文本框,让用户输入.我点保存时怎样才能将上面的信息放进empList中呢?
{
private String name;
private String sex;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
}
public class EmpForm extends ActionForm{
private List empList = new ArrayList();
public List getEmpList(){return this.empList;}
public void setEmpList(List empList)
{
this.empList = empList;
}
}
public class EmpAction extends Action
{
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
EmpForm empForm = (EmpForm) form;
if ("list".equals(empForm.getType())){
empFrom.setEmpList(EmpService.allEmp());//从数据库中取出
return mapping.findForward("list");
}
else{
EmpService.saveEmp(empForm.getEmpList());
rerturn mapping.findForward("save");
}
}
}
从数据库中取出Emp对象显示在页面上像这样
姓名 性别 年龄 添加
张三 男 20
李四 男 21
....
保存
点添加按钮时用javascript动态生成一行,文本框,下拉框,文本框,让用户输入.我点保存时怎样才能将上面的信息放进empList中呢?
解决方案 »
- JSP文件在项目文件夹下才能正常运行,如何控制jsp文件在目录中位置?
- 哪位大侠给我个ASP+ACCESS数据库的类似于耗材管理系统的源代码,谢谢了
- struts2 if条件的写法
- jsp页面无法获取action传来的session
- 新手关于hibernate 查询问题 高手进来
- jsp中的每月的1号
- FCKEditor无法保存问题
- 关于ORACLE 9i 执行SELECT top 10 * from tables order by id desc语句出错问题
- doOption()是什么方法?
- 概念请问: 一道SCJP程序员考试题
- 急啊,还在加班弄这个问题!!!!!!!!!!!!!!!!1
- 错误信息
<bean:define id="list" name="empListForm" property="empList"/>
<logic:empty name="list">
<bean:message key="message.system.empty"/>
</logic:empty>
<logic:iterate id="s" name="list">
${s.name}-----${s.sex}
</logic:iterate>
<br/>
${page.toolBar }
</logic:notEmpty>
<bean:write name ="Emp" property="name" />
</logic:iterate>