formbean:
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if ( (this.getUserName().trim().length() == 0)) {
errors.add("userName", new ActionError("errors.username.required"));
}
if ( (this.getPassWord().length() == 0)) {
errors.add("userpassword", new ActionError("errors.userpassword.required"));
}
return errors;
}struts-config.xml
<message-resources parameter="ApplicationResources" />ApplicationResources.properties
errors.username.required = <t1>\u7528\u6237\u540d\u4e0d\u80fd\u4e3a\u7a7a</t1><br>
errors.userpassword.required = <t1>\u5bc6\u7801\u4e0d\u80fd\u4e3a\u7a7a</t1><br>jsp:
<html:errors/>
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if ( (this.getUserName().trim().length() == 0)) {
errors.add("userName", new ActionError("errors.username.required"));
}
if ( (this.getPassWord().length() == 0)) {
errors.add("userpassword", new ActionError("errors.userpassword.required"));
}
return errors;
}struts-config.xml
<message-resources parameter="ApplicationResources" />ApplicationResources.properties
errors.username.required = <t1>\u7528\u6237\u540d\u4e0d\u80fd\u4e3a\u7a7a</t1><br>
errors.userpassword.required = <t1>\u5bc6\u7801\u4e0d\u80fd\u4e3a\u7a7a</t1><br>jsp:
<html:errors/>
解决方案 »
- struts2中url问题
- struts2 textfield标签使用问题
- struts2+spring整合之i18n问题
- 使用HibernateXML映射方式,可以使用<composite-id>元素来映射复合自然键,如果用Hibernate Annotation,对应的注解是什么?
- 还是乱码问题???~~~~~~~~~
- 请教各位星星大狭, 你们是用Eclipse还是用MyEclipse开发Web程序呢?
- 如何把文本写入数据库的过滤掉一些HTML符号?
- htmlUnit获取的页面中有VBScript错误
- 為什么用JSP連續兩次調用(WEBLOGIC7.0)SESSIONBEAN中同一個查詢方法﹐第2次并沒有在容器中真正執行﹐第2次的查詢結果總和第一次一樣
- jb8下的sql server连接问题?
- 视频聊天网站方面的软件需求:(初稿)
- weblogic.jar t3协议 的client:jdk1.4与jdk5不同报错,appletviewer.exe和sun.applet.AppletViewer不同报错
可是formbean的错误也不能在<html:errors/>输出,为什么啊?jsp的页面和程序都没有错误
编译后这个文件是不是变成空的了。以前我就遇到过
struts-config.xml
validate="true"
ActionMessage是ActionError的父类,所以一个ActionMessage的对象不能用于errors.add方法,反过来到可以