1、先写了个Beans 里面有 name password 属性,set get 方法都有。
2.再写了个action 里面有 Beans 对象beans 。
3.用配置文件校验
4.前台用html想显示错误信息,不用标签库。
显示错误的地方用${errors.bean.name[0]} 无法显示错误信息,但是把 beans 直接写在action 里面显示正常${errors.name[0]}.....
在线等 beans 和action 分开写 不用标签库显示错误信息的方法
2.再写了个action 里面有 Beans 对象beans 。
3.用配置文件校验
4.前台用html想显示错误信息,不用标签库。
显示错误的地方用${errors.bean.name[0]} 无法显示错误信息,但是把 beans 直接写在action 里面显示正常${errors.name[0]}.....
在线等 beans 和action 分开写 不用标签库显示错误信息的方法
<s:filederror fieldName="beans.name" />
<s:filederror fieldName="beans.password" />
记得是以列表的形式显示的, 因为一个字段上面可能会有多个错误!
${fieldErrors[beans.name][0]}
${fieldErrors[beans.password][0]}
在property标签中式这么取的.!
el能访问到valuestack中的属性,我想应该也是可以的.! 在struts2中没用过el! LZ自己去试
例子
ActionContext.getContext().put("message", "<font color='#0099CC'>恭喜您,添加上传广告成功!</font>");//设定页面返回信息