我把问题简化了,就是在actionform中的validate()方法中是public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors=new ActionErrors();
errors.add("username",new ActionMessage("没有选择列为group by"));
return errors;
}在jsp页面中是<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<html>
<head>
<title>JSP for ZzzzForm form</title>
</head>
<body>
<html:form action="/zzzz">
pwd : <html:text property="pwd"/><html:errors property="pwd"/><br/>
username : <html:text property="username"/><html:errors property="username"/><br/>
<html:submit/><html:cancel/>
</html:form>
</body>
</html>
validate肯定会返回错误,可是错误不会显示在页面上,为什么啊?
HttpServletRequest request) {
ActionErrors errors=new ActionErrors();
errors.add("username",new ActionMessage("没有选择列为group by"));
return errors;
}在jsp页面中是<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<html>
<head>
<title>JSP for ZzzzForm form</title>
</head>
<body>
<html:form action="/zzzz">
pwd : <html:text property="pwd"/><html:errors property="pwd"/><br/>
username : <html:text property="username"/><html:errors property="username"/><br/>
<html:submit/><html:cancel/>
</html:form>
</body>
</html>
validate肯定会返回错误,可是错误不会显示在页面上,为什么啊?
><html:errors property="username"/>不是也一样
this.reset(mapping, request);
errors.add("username", new ActionMessage("hello.no.username.error"));
}
你再改下看看行不行
就算你是测试,如果你不写判断,你的text框里有值,难道你也让validate抛message?
那你这种测试有什么意义呢?