Struts2 等价物 - actionError.get().hasNext() [英] Struts2 equivalent - actionError.get().hasNext()

查看:27
本文介绍了Struts2 等价物 - actionError.get().hasNext()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Struts2 中与 action 类中的以下行等效的内容是什么:

if(actionError.get("myError").hasNext()){....}

解决方案

ActionSupport 类中有一个方法 getActionErrors() 可以与代码一起使用><块引用>

getActionErrors集合<字符串>getActionErrors()获取此操作的操作级错误消息的`Collection`.

错误信息不应该直接添加在这里,因为实现可以自由返回新的 Collection不可修改的集合.

返回:字符串错误消息的集合

if (getActionErrors().contains("myError")) {//你的代码在这里}

What is the equivalent in Struts2 to the following line from action class:

if(actionError.get("myError").hasNext()){
....
}

解决方案

There's a method in ActionSupport class getActionErrors() that you can use along with the code

getActionErrors

Collection<String> getActionErrors()

Get the `Collection` of Action-level error messages for this action. 

Error messages should not be added directly here, as implementations are free to return a new Collection or an Unmodifiable Collection.

Returns:
    Collection of String error messages

and

if (getActionErrors().contains("myError")) {
  //your code here
}

这篇关于Struts2 等价物 - actionError.get().hasNext()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆