不显示ActionMessage?
页面输入不符合验证规则的时候,页面的确回到了输入界面,可惜就是不显示错误消息,这是怎么回事?
相关代码:
1、Jsp代码:
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html locale="true">
<head>
<html:base />
<title>wtest.jsp</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head>
<body>
<html:errors/>
.......
_______________________________________________________________________________
2、输入验证代码
public ActionErrors validate(
ActionMapping mapping,
HttpServletRequest request) {
//throw new UnsupportedOperationException(
// "Generated method 'validate(...)' not implemented.");
ActionErrors errors=new ActionErrors();
if(firstname.length()>10)
errors.add("firstname",new ActionMessage("firstname>10字符"));
return errors;
}