public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors=new ActionErrors();
for(int i=0;i<groupby.length;i++)
{
if(!groupby[i].equals("none"))
{
for(int j=0;j<groupby.length;j++)
{
if(groupby[j].equals("groupby"))
break;
if(j==groupby.length-1)
{
errors.add("errormesg",new ActionMessage("没有选择列为group by"));
return errors;
}
}
for(int j=0;j<groupby.length;j++)
{
if(groupby[j].equals("none"))
{
errors.add("errormesg",new ActionMessage(groupby[j]+"在选择列表中无效,因为该列既不包含在聚合函数中,也不包含在 GROUP BY 子句中"));
return errors;
}
if(groupby[j].equals("groupby")&&i!=j)
{
errors.add("errormesg",new ActionMessage("GROUP BY 子句中只能有一个列"));
return errors;
}
}
}
}
return null ;
}当返回错误的时候,怎么在我输入的页面上显示呢?
我在jsp页面是
<html:messages id="errormesg" message="true">
<bean:write name="errormesg"/>
</html:messages>但是不会跑出错误信息
HttpServletRequest request) {
ActionErrors errors=new ActionErrors();
for(int i=0;i<groupby.length;i++)
{
if(!groupby[i].equals("none"))
{
for(int j=0;j<groupby.length;j++)
{
if(groupby[j].equals("groupby"))
break;
if(j==groupby.length-1)
{
errors.add("errormesg",new ActionMessage("没有选择列为group by"));
return errors;
}
}
for(int j=0;j<groupby.length;j++)
{
if(groupby[j].equals("none"))
{
errors.add("errormesg",new ActionMessage(groupby[j]+"在选择列表中无效,因为该列既不包含在聚合函数中,也不包含在 GROUP BY 子句中"));
return errors;
}
if(groupby[j].equals("groupby")&&i!=j)
{
errors.add("errormesg",new ActionMessage("GROUP BY 子句中只能有一个列"));
return errors;
}
}
}
}
return null ;
}当返回错误的时候,怎么在我输入的页面上显示呢?
我在jsp页面是
<html:messages id="errormesg" message="true">
<bean:write name="errormesg"/>
</html:messages>但是不会跑出错误信息
但是我不知道格式怎么写
而且我试了<html:messages id="errormesg" property="errormesg"/> 也不行
我参照了一本书改了一下,现在就是说在actionform中有
errors.add(ActionErrors.GLOBAL_MESSAGE,new ActionMessage("没有选择列为group by"));
return errors;
上面的没错,我调试了发现错误有存入errors然而在jsp页面中我这么写]<html:messages id="errormesg" message="true">
<bean:write name="errormesg"/>
</html:messages>却不显示
如果要具体的话可以<html:error name="xxx"/>
就好了,<bean write>当然是不行的了
祝你好运啊
errors.add(ActionErrors.GLOBAL_MESSAGE,new ActionMessage("没有选择列为group by"));
return errors;
页面中
<html:errors/>
还是不显示是不是<html:errors/>要放在form里面还是什么的?