简体   繁体   English

我可以提交一个引用 POJO(即不仅仅是字符串或布尔值)字段的 Struts 表单吗?

[英]Can I submit a Struts form that references POJO (i.e. not just String or boolean) fields?

I have a Struts (1.3x) ActionForm that has several String and boolean properties/fields, but also has some POJO fields.我有一个 Struts (1.3x) ActionForm,它有几个 String 和 boolean 属性/字段,但也有一些 POJO 字段。

so my form looks something like:所以我的表格看起来像:

MyForm extends ActionForm {
    private String name;
    private int id;
    private Thing thing;

    ...getters/setters...
}

In the JSP I can reference the POJO's fields thusly:在 JSP 中,我可以这样引用 POJO 的字段:

<html:text property="thing.thingName" />

...and the values display correctly, but if I try to submit the form I get the ServletException: BeanUtils.populate error. ...并且值显示正确,但如果我尝试提交表单,我会收到 ServletException: BeanUtils.populate 错误。

There seems to be a lot of information about this general topic on the web, but none really addresses my specific question, which is: shouldn't I be able to submit a form in Struts that contains fields that are POJOs?网络上似乎有很多关于这个一般主题的信息,但没有一个真正解决我的具体问题,即:我不应该能够在 Struts 中提交包含 POJO 字段的表单吗?

You can, as long as the fields follow the JavaBean conventions and the setter takes something Struts can understand.您可以,只要字段遵循 JavaBean 约定并且 setter 采用 Struts 可以理解的内容。

So Thing needs getThingName() and setThingName(String) .所以Thing需要getThingName()setThingName(String)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Selenium:显式/无条件等待,即“等待” - Selenium: Explicit / Unconditional wait, i.e. "just wait" 在struts中,如何为Boolean接收null? - In struts, How can I receive null for Boolean? 文件上传缓慢:我可以从多部分 POST 数据中即时删除文件附件并只提交表单文本字段吗? - Slow file upload: Can I remove file attachment from multipart POST data on the fly and just submit form text fields? 我们可以用大小不同的其他行(即新字符串)替换文件中的行吗? - Can we replace a line from file with other line (i.e. new string) having different size? 如何找到对Java类的所有引用(即,依赖关系,传入耦合)? - How do I find all references (i.e., dependencies, afferent couplings) to a Java class? Google 自定义搜索与动态 Web 站点一起使用(即 Struts 2 + Tiles 2 with Spring)? - Google Custom Search Work with Dynamic Web Site (i.e. Struts 2 + Tiles 2 with Spring)? 在struts动作类中获取动态列数据(即在动作类中没有getter设置器) - Get dynamic column data(i.e. without getter setter in action classes) in struts action classes 使用String的JAVA 2D地图? 即“ +”和“ C” - JAVA 2D Map using String? i.e. “+” and “C” 我想使用spring 3在控制器的pojo中获取表单数据集,就像struts1.2方法一样 - I want to get the form data set in a pojo in my controller using spring 3, as like struts1.2 approach 使用Eclipse在Java文件中找到刚刚编写的代码(即突出显示代码的新部分) - Find the just written code in a java file with Eclipse (i.e. highlight the new part of code)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM