学习笔记--每周翻译点英文的reference

来源:互联网 发布:天刀钟汉良捏脸数据 编辑:程序博客网 时间:2024/06/11 18:38

在用struts2框架处理一个request 请求的时候主要使用三个类,Actions,Interceptors,and Results。可以使用一个或多个XMLdocument来配置



Framework Interceptors                                         Struts2中的Interceptors

Interceptor classes are also defined using a key-value pair specified in the Struts configuration file. The names specified below come specified instruts-default.xml. If you extend the struts-default package, then you can use the names below. Otherwise, they must be defined in your package with a name-class pair specified in the <interceptors> tag.

拦截器也是使用键值对(key-value)的形式配置在 Strusts的配置文件中,下面的拦截器都是被定义在 struts-default.xml中。如果你继承 struts-default 包,你就可以使用下面这些拦截器了。 不然的话,他们就必须使用name-class对的形式配置在你的struts.xml文件中


InterceptorNameDescriptionAlias InterceptoraliasConverts similar parameters that may be named differently between requests. 
在不同请求之间将请求参数在不同的名字间转换而请求内容不变Chaining InterceptorchainMakes the previous Action's properties available to the current Action. Commonly used together with <result type="chain"> (in the previous Action).
让前一个Action的属性可以被后一个Action使用Checkbox InterceptorcheckboxAdds automatic checkbox handling code that detect an unchecked checkbox and add it as a parameter with a default (usually 'false') value. Uses a specially named hidden field to detect unsubmitted checkboxes. The default unchecked value is overridable for non-boolean value'd checkboxes.
添加了checkbox自动处理代码,将没有选中的checkbox的内容设定为false,而html默认情况下不提交没有选中的checkboxCookie InterceptorcookieInject cookie with a certain configurable name / value into action. (Since 2.0.7.)
注入cookie到Action中,用已配置的name,valueConversion Error InterceptorconversionErrorAdds conversion errors from the ActionContext to the Action's field errors
将转换错误从ActionContext中添加到Action的错误属性字段中。Create Session InterceptorcreateSessionCreate an HttpSession automatically, useful with certain Interceptors that require a HttpSession to work properly (like the TokenInterceptor)
自动的创建HttpSession,用来为需要使用到HttpSession的拦截器服务。DebuggingInterceptordebuggingProvides several different debugging screens to provide insight into the data behind the page.
提供不同的调试用的页面来展现内部的数据状况。Execute and Wait InterceptorexecAndWaitExecutes the Action in the background and then sends the user off to an intermediate waiting page.
在后台执行Action,然后给用户展现一个中间的等待页面。Exception InterceptorexceptionMaps exceptions to a result.
将异常定位到一个result中去File Upload InterceptorfileUploadAn Interceptor that adds easy access to file upload support.
可以更容易的上传文件了I18n Interceptori18nRemembers the locale selected for a user's session.
记住用户的session中的locale信息Logger InterceptorloggerOutputs the name of the Action.
输出Action的名字Message Store InterceptorstoreStore and retrieve action messages / errors / field errors for action that implements ValidationAware interface into session.
存储和索引  实现ValidationAware接口的Action类  所出现的消息,错误,字段错误等信息。Model Driven InterceptormodelDrivenIf the Action implements ModelDriven, pushes the getModel Result onto the Value Stack.
如果Action实现了ModelDriven接口, 拦截器将把Action中的getModel的结果添加到ValueStack中去Scoped Model Driven InterceptorscopedModelDrivenIf the Action implements ScopedModelDriven, the interceptor retrieves and stores the model from a scope and sets it on the action callingsetModel.
如果一个Action实现了ScopedModelDriven,则这个拦截器会从相应的Scope中取出model调用ActionsetModel方法将其放入Action内部。
Parameters InterceptorparamsSets the request parameters onto the Action.
将请求中的参数设置到Action中去Prepare InterceptorprepareIf the Action implements Preparable, calls its prepare method.
如果Acton实现了Preparable接口,则该拦截器调用Action类的prepare方法。Scope InterceptorscopeSimple mechanism for storing Action state in the session or application scope.
Action状态存入sessionapplication的简单方法。Servlet Config InterceptorservletConfigProvide access to Maps representing HttpServletRequest and HttpServletResponse.
提供访问HttpServletRequestHttpServletResponse的方法,以Map的方式访问。Static Parameters InterceptorstaticParamsSets the struts.xml defined parameters onto the action. These are the <param> tags that are direct children of the <action> tag.
struts.xml文件中将<action>中的<param>中的内容设置到对应的Action中。Roles InterceptorrolesAction will only be executed if the user has the correct JAAS role.
确定用户是否具有JAAS指定的Role,否则不予执行。Timer InterceptortimerOutputs how long the Action takes to execute (including nested Interceptors and View)
输出Action实行execute方法花费的时间Token InterceptortokenChecks for valid token presence in Action, prevents duplicate form submission.
通过Token来避免重复提交,多次提交Token Session InterceptortokenSessionSame as Token Interceptor, but stores the submitted data in session when handed an invalid token
Token Interceptor一样,不过双击的时候把请求的数据存储在SessionValidation InterceptorvalidationPerforms validation using the validators defined in action-validation.xml
使用actionName-validation.xml文件中定义的内容校验提交的数据。Workflow InterceptorworkflowCalls the validate method in your Action class. If Action errors are created then it returns theINPUT view.
调用Actionvalidate方法,一旦有错误返回,重新定位到INPUT画面Parameter Filter InterceptorN/ARemoves parameters from the list of those available to Actions
从参数列表中删除不必要的参数Profiling InterceptorprofilingActivate profiling through parameter
通过参数激活profileMultiselect InterceptormultiselectLike the checkbox interceptor detects that no value was selected for a field with multiple values (like a select) and adds an empty parameter