actionutils.java
来自「是一个网站的博客系统」· Java 代码 · 共 38 行
JAVA
38 行
package com.opensource.blog.web.action;
import javax.servlet.http.*;
import org.apache.struts.action.*;
import org.apache.struts.*;
public class ActionUtils {
public ActionUtils() {
}
public synchronized static void addErrors(HttpServletRequest request, ActionMessages errors) {
if (errors == null) {
// bad programmer! *slap*
return;
}
// get any existing errors from the request, or make a new one
ActionMessages requestErrors = (ActionMessages) request.getAttribute(Globals.ERROR_KEY);
if (requestErrors == null) {
requestErrors = new ActionMessages();
}
// add incoming errors
requestErrors.add(errors);
// if still empty, just wipe it out from the request
if (requestErrors.isEmpty()) {
request.removeAttribute(Globals.ERROR_KEY);
return;
}
// Save the errors
request.setAttribute(Globals.ERROR_KEY, requestErrors);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?