不显示ActionMessage?

jaopen 2005-06-16 10:34:29
页面输入不符合验证规则的时候,页面的确回到了输入界面,可惜就是不显示错误消息,这是怎么回事?
相关代码:
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;
}
...全文
80 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
JohnWoo 2005-06-16
  • 打赏
  • 举报
回复
faint没有想到。
handysoft 2005-06-16
  • 打赏
  • 举报
回复
看一下,struts-config.xml中
<action
...
...
validate="true">
JohnWoo 2005-06-16
  • 打赏
  • 举报
回复
看了代码,好像跟你贴上来的内容无关。
看看别的地方吧。
jaopen 2005-06-16
  • 打赏
  • 举报
回复
还是原输入界面,在<html:error/>那个位置什么都没有,
JohnWoo 2005-06-16
  • 打赏
  • 举报
回复
那显示什么?

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧