Struts2拦截器----AliasInterceptor分析(二)

2014-11-24 08:14:27 · 作者: · 浏览: 1
rror(developerNotification); if (action instanceof ValidationAware) { ((ValidationAware) action).addActionMessage(developerNotification); } } } } } if (clearableStack && (stack.getContext() != null) && (newStack.getContext() != null)) stack.getContext().put(ActionContext.CONVERSION_ERRORS, newStack.getContext().get(ActionContext.CONVERSION_ERRORS)); } else { if (LOG.isDebugEnabled()) { LOG.debug("invalid alias expression:" + aliasesKey); } } } return invocation.invoke(); }

拦截器有一个参数:aliasesKey,可通过在struts.xml中定义该拦截器时指定其值,默认值是aliases,表示一个别名的map。param标签的name属性值应该和拦截器参数aliasesKey的值一样,这样拦截器才知道你是否指定了action的别名map。

1:得到struts.xml中action的paramters。

2:看是否包含了aliasesKey,如果包含了,那么说明存在一个别名map。

3:迭代这个map中的每项,将该项的别名和值也写入值栈中。