与我英文名同名的作品:传说的1983!《少年sundy》怀旧本惊现秋叶原

by sundy 8/7/2009 3:31:49 PM

月15日,一套怀旧本《少年sundy-1983》惊现秋叶原,这本包含9篇特选的曾在1983年于《少年sundy》漫画杂志上连载的作品,之所以选1983年的作品是因为当时该刊漫画连载量是目前为止最多的同时汇集了众多著名的漫画家的作品,更有人称之为“传说中的1983”。其中大部分都是大家所熟悉的如安达充成名作《棒球英豪》高桥留美子的《福星小子》以及岛本和彦的《炎之转校生》等。排版形式也和80年代一样的风格,怀旧味满载!

39_143958_3e0387442261eb1  39_143958_68d899dfaaa2636
而说到《少年sundy》,可谓是日本数一数二的漫画周刊。自1959年开始创刊,50年来多次创造了惊人的销量,与集英社的《少年jump》难分高下,我们著名的矮冬瓜柯南就是在这本杂志上连载,是日本小学馆镇馆之本。这次所发售的怀旧特辑其实也是为了纪念周刊连载50周年而特别企划的周年增刊。所以单是凭借多位漫画大神的人气,相信也会有很好的销量

39_143958_6db9dc69dff0e0b39_143958_c3c41310d37fe81

39_143958_5411a4a8bc0dece  39_143958_f95e8451e4dcebf

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Game Life

Struts源码分析4:ActionForward

by sundy 8/7/2009 11:57:40 AM

前言:发现很多j2ee的程序员基础都差得不行 ,会用ssh的甚至都不知道为何要这样,以及如何设计的 。因此为大家简单的剖析一下Struts的设计 ,以资借鉴 。

ActionForward继承了下ForwardConfig,然后就写了6个构造函数……然后就没了 汗=。=!
有一句话没翻译出来,有看得懂的来帮个忙吧 :
NOTE - This class would have been deprecated and
replaced by org.apache.struts.config.ForwardConfig except for the fact that
it is part of the public API that existing applications are using.
下面是翻译后的源码。

package org.apache.struts.action;
import org.apache.struts.config.ForwardConfig;
/**
* 一个ActionForward为控制器类RequestProcessor指向了一个目的地,由控制器执行跳转。
* 但也可能作为Action中的行为,直接执行RequestDispatcher.forward或
* HttpServletResponse.sendRedirect方法。这个类的实例可以会根据需要被动态创建,
* 也可以被设定为与一个ActionMapping绑定,通过名字查找这个mapping实例的多个跳转目的地。

* 一个ActionForward包含以下几个基本属性,其他的附加属性可以根据需要由子类提供。

* contextRelative(上下文关系): path路径值必须被解释为上下文相关路径(context-relative)

* name : 用来查找相关的ActionMapping。
* <li><strong>name</strong> - Logical name by which this instance may be
* looked up in relationship to a particular ActionMapping. </li>
*
* path : 一个让控制器实现转发(forward)的,模型相关/上下文相关URI;或一个让控制器
* 实现重定向(redirected)的,绝对/相对URI。
*
* redirect : 当需要控制器以重定向的方法执行path时则设为true,否则为false
*
* 这个类继承了 ForwardConfig 类和 contextRelative属性
*
* 注意 :这个类不推荐使用,而应由ForwardConfig取代 ..后面的翻不出来了。
* NOTE - This class would have been deprecated and
* replaced by org.apache.struts.config.ForwardConfig except for the fact that
* it is part of the public API that existing applications are using.</p>
*          
*/
public class ActionForward extends ForwardConfig {
/**
     * 无参构造函数 - 以默认值实例化
*/
public ActionForward() {
this(null, false);
    }
/**
     * 构造函数 - 参数path</p>
     *
*/
public ActionForward(String path) {
this(path, false);
    }
/**
     * 构造函数 - 参数 path,redirect
*/
public ActionForward(String path, boolean redirect) {
super();
        setName(null);
        setPath(path);
        setRedirect(redirect);
    }
/**
     *构造函数 - 参数 name,path,redirect
*/
public ActionForward(String name, String path, boolean redirect) {
super();
        setName(name);
        setPath(path);
        setRedirect(redirect);
    }
/**
     * 构造函数 - 参数 name,path,redirect,module 模块前缀
*/
public ActionForward(String name, String path, boolean redirect,
        String module) {
super();
        setName(name);
        setPath(path);
        setRedirect(redirect);
        setModule(module);
    }
/**
     * 构造函数 - 用已有的ActionForward对象实例化。
*/
public ActionForward(ActionForward copyMe) {
this(copyMe.getName(), copyMe.getPath(), copyMe.getRedirect(),
            copyMe.getModule());
    }
}

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Java & OpenSource Domain

Struts源码分析3:ActionForm

by sundy 8/7/2009 11:56:30 AM

前言:发现很多j2ee的程序员基础都差得不行 ,会用ssh的甚至都不知道为何要这样,以及如何设计的 。因此为大家简单的剖析一下Struts的设计 ,以资借鉴 。

import org.apache.struts.upload.MultipartRequestHandler;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
/**
* 一个ActionForm是可以与一个或多个任意的ActionMapping关联的JavaBean。这个bean的里属性
* 在对应Action.execute方法调用前,由对应的request初始化。    
*
* 当这个bean的属性被赋值后,Action.execute方法调用之前,bean的validate方法
* 将被调用,这个方法用来校验用户提交的属性值。如果发现错误,就返回一个包含了这些错误内容的
* error信息。controller将返回至相应的输入表单。如果无错误,validate方法就返回null,
* 相应的Action.execute方法将被调用。

* 这个类必须被继承使用。子类要为所有会被公开(expose)的bean属性提供get和set方法,以及
* 重写一些public或protected方法以提供具体实现。

* 由于ActionForm是JavaBeans,所以根据JavaBeans的规范,子类也会实现Serializable(可序列
* 化)接口。为了使用ActionForm相关的introspection API ?,一些容器会要求一个Form对象满足
* 所有JavaBean规范。

*/
public abstract class ActionForm implements Serializable {
// ----------------------------------------------------- Instance Variables
/**
     * <p>The servlet instance to which we are attached.</p>
*/
protected transient ActionServlet servlet = null;
/**
     * MultipartRequestHandler
     * 这个form的多请求处理对象。        //transient表示该属性将不被序列化。
     *  //wzl注:该对象的作用大约是结合upload包里的类,实现文件的上传功能。
     *  //由于还没接触过,所以下面的相关方法不再翻译
*/
protected transient MultipartRequestHandler multipartRequestHandler;
// ------------------------------------------------------------- Properties
/**
     * @return The servlet instance to which we are attached.
*/
protected ActionServlet getServlet() {
return (this.servlet);
    }
/**
     * ActionServletWrapper
     * 将所属的控制器servlet以ActionServletWrapper对象返回。
     * //该对象也在servlet上提供了对MultipartRequestHandler的使用。
     * @return An instance of ActionServletWrapper
*/
public ActionServletWrapper getServletWrapper() {
return new ActionServletWrapper(getServlet());
    }
/**
     * <p>Return the <code>MultipartRequestHandler</code> for this form The
     * reasoning behind this is to give form bean developers control over the
     * lifecycle of their multipart requests through the use of the
     * <code>finish</code> and/or <code>rollback</code> methods of
     * <code>MultipartRequestHandler</code>.  This method will return
     * <code>null</code> if this form's enctype is not "multipart/form-data".
     * </p>
     * 
     * @return The {@link org.apache.struts.upload.MultipartRequestHandler}
     *         for this form.
     * @see org.apache.struts.upload.MultipartRequestHandler
*/
public MultipartRequestHandler getMultipartRequestHandler() {
return multipartRequestHandler;
    }
/**
     * 设定所属的servlet(若非空)实例。
     *
     * @param servlet The new controller servlet, if any
*/
public void setServlet(ActionServlet servlet) {
this.servlet = servlet;
// :FIXME: Should this be releasing resources?
    }
/**
     * <p>Set the Handler provided for use in dealing with file uploads.</p>
     *
     * @param multipartRequestHandler The Handler to use for fileuploads.
*/
public void setMultipartRequestHandler(
        MultipartRequestHandler multipartRequestHandler) {
this.multipartRequestHandler = multipartRequestHandler;
    }
// --------------------------------------------------------- Public Methods
/**
     *  //直接调用下面那个重载HTTP的。
*/
public void reset(ActionMapping mapping, ServletRequest request) {
try {
            reset(mapping, (HttpServletRequest) request);
        } catch (ClassCastException e) {
            ; // FIXME: Why would this ever happen except a null
        }
    }
/**
     * 用来重置bean中的属性。这个方法在属性被控制器赋值前调用。
     * 
     * 默认的方法体为空,实际中发现,唯一需要被重置的是声明到session中表单的checkboxs属性
     * 除此以外的属性,都会在域声明时被初始化。
     * 
     * 如果为了实现form能被多个请求取值而将其放到了session中,那么你必须非常注意那些被
     * 重置(reset)的值,如上面提到的,对于每一个输入表单内容的页面,必须将session范围中的
     * checkboxs提前重置为fales。这是因为只有当checkbox为fales时才表示客户没有提交该值。
     * 如果一个session中的checkbox没有被提前重置的话,他将永远不会为fales。
     * 
     * 这个方法不适合用来给"修改"类型的页面中的表单赋初始值(这应该在setup Action中)。你唯一需要
     * 关心的就是将checkbox的值改为fales。所以这个方法一般不用实现
     * 
     * @param mapping The mapping used to select this instance
     * @param request The servlet request we are processing
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
// Default implementation does nothing
    }
/**
     *  //直接调用下面那个重载HTTP的。
*/
public ActionErrors validate(ActionMapping mapping, ServletRequest request) {
try {
return (validate(mapping, (HttpServletRequest) request));
        } catch (ClassCastException e) {
return (null);
        }
    }
/**
     * 用来验证request中的属性值,并返回一个ActionErrors对象,它包含了验证中发现的错误信息。
     * 如果验证成功,则返回null 或一个无错误信息记录的ActionErrors对象。
     * 
     * 默认的执行体为空并返回null,子类中必须重写这个方法以提供需要的验证操作。
     * 
     * @param mapping The mapping used to select this instance
     * @param request The servlet request we are processing
     * @return 验证失败就返回错误信息; 验证成功则返回null或空的信息。
     *         
     * @see DynaActionForm
*/
public ActionErrors validate(ActionMapping mapping,
        HttpServletRequest request) {
return (null);
    }
}

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Java & OpenSource Domain

Struts源码分析2:org.apache.struts.action.ActionErrors

by sundy 8/7/2009 11:54:47 AM

前言:发现很多j2ee的程序员基础都差得不行 ,会用ssh的甚至都不知道为何要这样,以及如何设计的 。因此为大家简单的剖析一下Struts的设计 ,以资借鉴 。

ActionErrors的源代码:

package org.apache.struts.action; 
import java.io.Serializable;
/**
*  一个用来压缩 (encapsulates) 错误信息的类。错误信息来自ActionForm的validate()的方法。
*  验证错误可能与整个ActionForm bean相关,也可能只针对一个bean属性。
*
*
* 每个单独的错误由一个ActionMessager对象来描述。
* 一个ActionMessager包含一个massage key。
*and up to four placeholder arguments used for parametric substitution in the resulting message.
*等于用于在resulting message中进行参数替换的4个占位符(placeholder)属性。??

*
* IMPLEMENTATION (执行) NOTE:假定这些对象在创建和操作中都
* 在同一个线程中,因此不需要同步。
*
*/
public class ActionErrors extends ActionMessages implements Serializable {
// --------------------------------------------------------- Public Methods
/**
     *  构造方法:创建空的 ActionErrors对象。
*/
public ActionErrors() {
super();
    }
/**
     * 用给的的Messages 初始化创建 ActionErrors对象    
     * @param messages The messages to be initially added to this object. This
     *                 parameter can be null
*/
public ActionErrors(ActionErrors messages) {
super(messages);
    }
}

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Java & OpenSource Domain

Struts源码分析1:org.apache.struts.action.Action

by sundy 8/7/2009 11:53:32 AM

前言:发现很多j2ee的程序员基础都差得不行 ,会用ssh的甚至都不知道为何要这样,以及如何设计的 。因此为大家简单的剖析一下Struts的设计 ,以资借鉴 。

actoin中的方法 大多是针对 Messages,Errors,token的一些操作。

package org.apache.struts.action;
import org.apache.struts.Globals;
import org.apache.struts.config.ModuleConfig;
import org.apache.struts.util.MessageResources;
import org.apache.struts.util.ModuleUtils;
import org.apache.struts.util.RequestUtils;
import org.apache.struts.util.TokenProcessor;
import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.Locale;
/**
*  Action必须以线程安全的方式编写,
* 因为controller会为同时存在的多个request共享一个实例。
* 所以编写时要注意:
*
* 实例和static变量不能存储与具体request相关的信息。
*
*  存取受保护的JavaBeans, session 变量等资源时,必须使用同步(synchronized)。

*
*  当一个Action实例被第一次创建时,controller会用一个非空参数
*(标识这个servlet实例和附属他的Action)调用 setServlet 。
*   当实例被关闭时,setServlet会被再次调用,用一个null
*   参数来清空这个Action的信息
*          
*/
public class Action {
/**
     * org.apache.struts.util.TokenProcessor类:令牌产生器,用于防止事务重复提交 
*/
private static TokenProcessor token = TokenProcessor.getInstance();
// NOTE: We can make the token  variable protected and remove Action's
// token methods or leave it private and allow the token methods to
// delegate(委托) their calls.
// ----------------------------------------------------- Instance Variables
/**
     * Action附属的servlet。
*/
protected transient ActionServlet servlet = null;
// ------------------------------------------------------------- Properties
public ActionServlet getServlet() {
return (this.servlet);
    }
/**
     * 设置Action附属的servlet,或释放所有资源(servlet=null)       
     * @param servlet The new controller servlet, if any
*/
public void setServlet(ActionServlet servlet) {
this.servlet = servlet;
// :FIXME: Is this suppose to release resources?
    }
// --------------------------------------------------------- Public Methods
/**
     *      非HTTP的execute方法,一般不用。
     * /
    public ActionForward execute(ActionMapping mapping, ActionForm form,
        ServletRequest request, ServletResponse response)
        throws Exception {
        try {
            return execute(mapping, form, (HttpServletRequest) request,
                (HttpServletResponse) response);
        } catch (ClassCastException e) {
            return null;
        }
    }
    /**
     * 处理 HTTP request, 创建相应的(corresponding)
     * HTTP response (或定向到其他创建response 的组件
     * ), 返回 { ActionForward} 实例 来通知control如何跳转。
     * 或当处理完成时返回null
     * 注:当请求发送到Action时就会自动执行这个execute方法,所以一般简单的Action就重写这个方法即可//by wzl.
     * @param mapping  The ActionMapping used to select this instance (用来选择这个实例??)
     * @param form     可选的 ActionForm bean 
     * @param request  The HTTP request 
     * @param response The HTTP response 
     * @return forward  通知 control 应该跳转的页面, 或null (当业务完成时)
     * @throws Exception if the application business logic throws an
     *                   exception
     * @since Struts 1.1
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
throws Exception {
return null;
    }
// ---------------------------------------------------- Protected Methods
/**
     * 为request添加 messages 
     * 在JSP用用 < html:messages> 标签使用 (if messages="true" is set),
     *  参数message 必须被初始化                                                          //org.apache.struts.action.ActionMessages 
     *  Otherwise, ensure that the request attribute is not set.???
     *
     * @param request  被添加message的request请求
     * @param messages ActionMessages 需要添加的message
     * @since Struts 1.2.1
*/
protected void addMessages(HttpServletRequest request,
        ActionMessages messages) {
if (messages == null) {
//  bad programmer! *slap*
return;
        }
// 取得request中的requestMessages, 没有就创建一个
        ActionMessages requestMessages =
            (ActionMessages) request.getAttribute(Globals.MESSAGE_KEY);   //"org.apache.struts.action.ACTION_MESSAGE";
if (requestMessages == null) {
            requestMessages = new ActionMessages();
        }
// messages加入到requestMessages
        requestMessages.add(messages);
// if still empty, just wipe it out from the request
if (requestMessages.isEmpty()) {
            request.removeAttribute(Globals.MESSAGE_KEY);
return;
        }
// Save the messages
        request.setAttribute(Globals.MESSAGE_KEY, requestMessages);
    }
/**
     * Adds the specified errors keys into the appropriate request attribute
     * for use by the &lt;html:errors&gt; tag, if any messages are required.
     * Initialize the attribute if it has not already been. Otherwise, ensure
     * that the request attribute is not set.
     *  注:基本与addMessages相同,只是这里的ActionMessages含的是错误信息,在页面用 <html:errors>使用。/by wzl
     * @param request The servlet request we are processing
     * @param errors  Errors object
     * @since Struts 1.2.1
*/
protected 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);
    }
/**
     * <p>Generate a new transaction token, to be used for enforcing a single
     * request for a particular transaction.</p>
     * 为需要处理特殊事务的request生成一个 事务token
     * @param request The request we are processing
     * @return The new transaction token.
*/
protected String generateToken(HttpServletRequest request) {
return token.generateToken(request);
    }
/**
     * Retrieves any existing errors placed in the request by previous
     * actions. This method could be called instead of creating a <code>new
     * ActionMessages()</code> at the beginning of an <code>Action</code>.
     * This will prevent saveErrors() from wiping out any existing Errors
     *
     * 获得被上一个Action设置的error信息,这个方法可用来
     *初始化一个ActionMessages。可以用来防止saveErrors()清空已存在的Errors。
     *
     * @param request The servlet request we are processing
     * @return the Errors that already exist in the request, or a new
     *         ActionMessages object if empty.
     * @since Struts 1.2.1
*/
protected ActionMessages getErrors(HttpServletRequest request) {
        ActionMessages errors =
            (ActionMessages) request.getAttribute(Globals.ERROR_KEY);
if (errors == null) {
            errors = new ActionMessages();
        }
return errors;
    }
/**
     * 返回用户当前选择的 Locale。  //java.util.Locale 对象表示了特定的地理、政治和文化地区。
     *
     * @param request The request we are processing
     * @return The user's currently selected Locale.
*/
protected Locale getLocale(HttpServletRequest request) {
return RequestUtils.getUserLocale(request, null);
    }
/**
     * 大体同getError(request)
     * <p> Retrieves any existing messages placed in the request by previous
     * actions. This method could be called instead of creating a <code>new
     * ActionMessages()</code> at the beginning of an <code>Action</code> This
     * will prevent saveMessages() from wiping out any existing Messages </p>
     * 
     * @param request The servlet request we are processing
     * @return the Messages that already exist in the request, or a new
     *         ActionMessages object if empty.
     * @since Struts 1.2.1
*/
protected ActionMessages getMessages(HttpServletRequest request) {
        ActionMessages messages =
            (ActionMessages) request.getAttribute(Globals.MESSAGE_KEY);
if (messages == null) {
            messages = new ActionMessages();
        }
return messages;
    }
/**
     * 为当前模型返回默认的MessageResources         ?? //org.apache.struts.util.MessageResources 
     *
     * @param request The servlet request we are processing
     * @return The default message resources for the current module.
     * @since Struts 1.1
*/
protected MessageResources getResources(HttpServletRequest request) {
return ((MessageResources) request.getAttribute(Globals.MESSAGES_KEY));
    }
/**
     * <p>Return the specified message resources for the current module.</p>
     * 根据key为当前module返回特定的MessageResources
     * 看不懂
     * @param request The servlet request we are processing
     * @param key     The key specified in the message-resources element for
     *                the requested bundle.
     * @return The specified message resource for the current module.
     * @since Struts 1.1
*/
protected MessageResources getResources(HttpServletRequest request,
        String key) {
// Identify the current module
        ServletContext context = getServlet().getServletContext();
        ModuleConfig moduleConfig =
            ModuleUtils.getInstance().getModuleConfig(request, context);
// Return the requested message resources instance
return (MessageResources) context.getAttribute(key
+ moduleConfig.getPrefix());
    }
/**
     * <p>Returns <code>true</code> if the current form's cancel button was
     * pressed. This method will check if the <code>Globals.CANCEL_KEY</code>
     * request attribute has been set, which normally occurs if the cancel
     * button generated by <strong>CancelTag</strong> was pressed by the user
     * in the current request. If <code>true</code>, validation performed by
     * an <strong>ActionForm</strong>'s <code>validate()</code> method will
     * have been skipped by the controller servlet.</p>
     *
     * 当form的cancel按键?被按下时返回true。该方法会检查 request的
     *  Globals.CANCEL_KEY属性。若为true,ActionForm中的validate()将被跳过。
     *
     * <p> Since Action 1.3.0, the mapping for a cancellable Action must also have
     * the new "cancellable" property set to true. If "cancellable" is not set, and
     * the magic Cancel token is found in the request, the standard Composable
     * Request Processor will throw an InvalidCancelException. </p>
     *
     * @param request The servlet request we are processing
     * @return <code>true</code> if the cancel button was pressed;
     *         <code>false</code> otherwise.
*/
protected boolean isCancelled(HttpServletRequest request) {
return (request.getAttribute(Globals.CANCEL_KEY) != null);
    }
/**
     * 在当前session中存有事务token时 返回true。当存在以下情况时返回false:
     * <ul>
     *
     *  request中无session
     * 
     * session中无事务token
     * <li>No transaction token included as a request parameter</li>
     * request中没有事务token属性。
     *
     * 存在是事务token属性与session中的不匹配。
     * </ul>
     *
     * @param request The servlet request we are processing
     * @return <code>true</code> if there is a transaction token and it is
     *         valid; <code>false</code> otherwise.
*/
protected boolean isTokenValid(HttpServletRequest request) {
return token.isTokenValid(request, false);
    }
/**
     * <p>Return <code>true</code> if there is a transaction token stored in
     * the user's current session, and the value submitted as a request
     * parameter with this action matches it. Returns <code>false</code> under
     * any of the following circumstances:</p>
     * 重写上一个方法,添加参数 reset 决定是否在确认后重置token
     * <ul>
     *
     * <li>No session associated with this request</li> <li>No transaction
     * token saved in the session</li>
     *
     * <li>No transaction token included as a request parameter</li>
     *
     * <li>The included transaction token value does not match the transaction
     * token in the user's session</li>
     * 
     * </ul>
     *
     * @param request The servlet request we are processing
     * @param reset   Should we reset the token after checking it?
     * @return <code>true</code> if there is a transaction token and it is
     *         valid; <code>false</code> otherwise.
*/
protected boolean isTokenValid(HttpServletRequest request, boolean reset) {
return token.isTokenValid(request, reset);
    }
/**
     * <p>Reset the saved transaction token in the user's session. This
     * indicates that transactional token checking will not be needed on the
     * next request that is submitted.</p>
     * 重置token
     * @param request The servlet request we are processing
*/
protected void resetToken(HttpServletRequest request) {
        token.resetToken(request);
    }
/**
     * <p>Save the specified error messages keys into the appropriate request
     * attribute for use by the &lt;html:errors&gt; tag, if any messages are
     * required. Otherwise, ensure that the request attribute is not
     * created.</p>
     * 重置并设置Errors。
     * @param request The servlet request we are processing
     * @param errors  Error messages object
     * @since Struts 1.2
*/
protected void saveErrors(HttpServletRequest request, ActionMessages errors) {
// Remove any error messages attribute if none are required
if ((errors == null) || errors.isEmpty()) {
            request.removeAttribute(Globals.ERROR_KEY);
return;
        }
// Save the error messages we need
        request.setAttribute(Globals.ERROR_KEY, errors);
    }
/**
     * <p>Save the specified messages keys into the appropriate request
     * attribute for use by the &lt;html:messages&gt; tag (if messages="true"
     * is set), if any messages are required. Otherwise, ensure that the
     * request attribute is not created.</p>
     * 重置并设置request中的Messages
     * @param request  The servlet request we are processing.
     * @param messages The messages to save. <code>null</code> or empty
     *                 messages removes any existing ActionMessages in the
     *                 request.
     * @since Struts 1.1
*/
protected void saveMessages(HttpServletRequest request,
        ActionMessages messages) {
// Remove any messages attribute if none are required
if ((messages == null) || messages.isEmpty()) {
            request.removeAttribute(Globals.MESSAGE_KEY);
return;
        }
// Save the messages we need
        request.setAttribute(Globals.MESSAGE_KEY, messages);
    }
/**
     * <p>Save the specified messages keys into the appropriate session
     * attribute for use by the &lt;html:messages&gt; tag (if messages="true"
     * is set), if any messages are required. Otherwise, ensure that the
     * session attribute is not created.</p>
     *  重置并设置session中的Messages
     * @param session  The session to save the messages in.
     * @param messages The messages to save. <code>null</code> or empty
     *                 messages removes any existing ActionMessages in the
     *                 session.
     * @since Struts 1.2
*/
protected void saveMessages(HttpSession session, ActionMessages messages) {
// Remove any messages attribute if none are required
if ((messages == null) || messages.isEmpty()) {
            session.removeAttribute(Globals.MESSAGE_KEY);
return;
        }
// Save the messages we need
        session.setAttribute(Globals.MESSAGE_KEY, messages);
    }
/**
     * <p>Save the specified error messages keys into the appropriate session
     * attribute for use by the &lt;html:messages&gt; tag (if
     * messages="false") or &lt;html:errors&gt;, if any error messages are
     * required. Otherwise, ensure that the session attribute is empty.</p>
     * 重置并设置session中的Errors
     * @param session The session to save the error messages in.
     * @param errors  The error messages to save. <code>null</code> or empty
     *                messages removes any existing error ActionMessages in
     *                the session.
     * @since Struts 1.3
*/
protected void saveErrors(HttpSession session, ActionMessages errors) {
// Remove the error attribute if none are required
if ((errors == null) || errors.isEmpty()) {
            session.removeAttribute(Globals.ERROR_KEY);
return;
        }
// Save the errors we need
        session.setAttribute(Globals.ERROR_KEY, errors);
    }
/**
     * <p>Save a new transaction token in the user's current session, creating
     * a new session if necessary.</p>
     * 
     * @param request The servlet request we are processing
*/
protected void saveToken(HttpServletRequest request) {
        token.saveToken(request);
    }
/**
     * <p>Set the user's currently selected <code>Locale</code> into their
     * <code>HttpSession</code>.</p>
     *
     * @param request The request we are processing
     * @param locale  The user's selected Locale to be set, or null to select
     *                the server's default Locale
*/
protected void setLocale(HttpServletRequest request, Locale locale) {
        HttpSession session = request.getSession();
if (locale == null) {
            locale = Locale.getDefault();
        }
        session.setAttribute(Globals.LOCALE_KEY, locale);
    }
}

Currently rated 4.5 by 2 people

  • Currently 4.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Java & OpenSource Domain

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.
© Copyright 2007 - 2008 Design by Sundy Linghua-Zhang 蜀ICP备08108648号

About the author

Name of author Author name
Something about me and what I do.

E-mail me Send mail

Calendar

<<  August 2009  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456

View posts in large calendar

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2012

Sign in