Struts2 等效 - actionError.get().hasNext()

Struts2 equivalent - actionError.get().hasNext()

Struts2 中的等价于操作 class 中的以下行:

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

ActionSupport class getActionErrors() 中有一个方法可以与代码一起使用

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

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