ITeye博客

OGNL的使用----Action提示信息

gu6866 · 2012-08-24 14:05 · Struts · JSTL&OGNL · 开源软件 · Markdown

使用Struts2标签必须先导入标签库,在页面使用如下代码导入Struts2标签:
<%@taglib prefix="s" uri="/struts-tags"%>

 

 

actionerror和actionmessage标签:

这两个标签都是用来输出Action实例里封装的信息,actionerror负责输出Action实例的getActionErrors()方法的返回值。actionmessage负责返回Action实例的getActionMessages()方法的返回值。

 

Action代码:

 

public Class TestAction{
  public String execute(){
    addActionError("出错了!"); 
    addActionMessage("请联系系统管理员!");
  }
}

 

在页面中使用标签输出:

<s:actionerror/>
<s:actionmessage/>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。