且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Struts2 等价物 - actionError.get().hasNext()

更新时间:2023-10-21 08:36:16

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
}