在struts中怎样在Action中手动填充Action Form? 我的原意是想在action中从数据库中检索出信息填充到action form中,然后前台页面表单的<html:text..等标签就可以获取值了.请问在action中怎样手动填充action form? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //普通的formbeanf.setXX(rs.getString("xx"));or//dynamicformbeanf.set("xx",rs.getString("xx")); Student stu=new Student();stu.setNu("00001");stu.setName("张海");StudentForm stuForm=(StudentForm)form;form.setStudent();-------------------------你的actionform中这样定义:public class StudentForm extends ActionForm { private Student student=new Student();}jsp:<html:text property="student.name" /> >>>//form.setStudent();stuForm.setStudent(stu); public class StudentForm extends ActionForm { private Student student=new Student(); .......get,setStudent方法} 不明白.请说清楚点,在action要怎么样做才能使前台页面HTML标签访问的Action Form中有数据?是下面这样吗?public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { CorpForm corpForm = (CorpForm) form; ... corpForm.set(); .... form=corpForm; return mapping.findForward("modify"); } 不过这句form=corpForm;是画蛇添足了 哎,还是我自己琢磨出来了.正确的应该这样做:public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { CorpForm corpForm = (CorpForm) form; ... corpForm.set(); .... request.setAttribute("corpInfoForm", corpForm);//corpInfoForm必须是struts-config.xml中设置的名称 return mapping.findForward("modify"); }这样前台页面的struts标签中就有数据了 request.setAttribute("corpInfoForm", corpForm);//这句话多余 struts-config.xml中你设置的form的scope是什么? 基于MVC开发模式的WEB应用一个小问题…… webgis做最优路径选择 tomcat要下载哪个版本呢 一个奇怪的调用js文件的问题,请各位帮忙! 关于带有复选框的树的问题(100分) java中的异常处理 有关checkbox简单的程序代码!? tomcat4*的版本最多可以支持多少个连接? tomcat下面的jsp页面不报错误,对于错误的jsp代码,在页面上没有任何错误提示,显示空白页面 关于浏览器涮新的奇怪问题 如何把int,string等多个类型放到一个byte[]数组里面啊,我想用socket发出去 JSP中如何才能将数据转换成Excel格式!!并提供下载!!
f.setXX(rs.getString("xx"));
or
//dynamicformbean
f.set("xx",rs.getString("xx"));
stu.setNu("00001");
stu.setName("张海");
StudentForm stuForm=(StudentForm)form;
form.setStudent();
-------------------------
你的actionform中这样定义:
public class StudentForm extends ActionForm {
private Student student=new Student();
}
jsp:
<html:text property="student.name" />
stuForm.setStudent(stu);
private Student student=new Student();
.......get,setStudent方法
}
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
CorpForm corpForm = (CorpForm) form;
...
corpForm.set();
....
form=corpForm;
return mapping.findForward("modify");
}
form=corpForm;
是画蛇添足了
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
CorpForm corpForm = (CorpForm) form;
...
corpForm.set();
....
request.setAttribute("corpInfoForm", corpForm);//corpInfoForm必须是struts-config.xml中设置的名称
return mapping.findForward("modify");
}
这样前台页面的struts标签中就有数据了