`

StrutsActionForm中BigDecimal使用和下拉列表的实现

阅读更多
在ActionForm中使用BigDecimal,如果页面没有输入内容就提交表单,会出现BeanUtils.ConversionException。具体内容不同版本的common BeanUtils也不一样,大致原因是Byte、Integer、Float、BigDecimal等等数据,当输入的string.length()==0时,就抛异常。

解决办法,在web.xml中加入如下内容

    <init-param>
   		<param-name>convertNull</param-name> 
   		<param-value>true</param-value>
    </init-param>


====================================================================================

使用Struts标签,实现下拉列表
在ActionForm中
private Collection values;
private String selectValue;

在Action中
ArrayList optionvalues = new ArrayList();
optionvalues.add(new LabelValueBean("label1","1"));
optionvalues.add(new LabelValueBean("label2","2"));
optionvalues.add(new LabelValueBean("label3","3"));
actionForm.setValues(optionvalues);

jsp页面
<html:select property="selectValue">
    <html:optionsCollection property="values"/>
</html:select>


页面一出现property 就回去From中找。。。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics