ActionUtils.java
资源名称:Myblog.rar [点击查看]
上传用户:wlfwy2004
上传日期:2016-12-12
资源大小:33978k
文件大小:1k
源码类别:
Jsp/Servlet
开发平台:
Java
- 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);
- }
- }