JavaScud | Forum | JIRA | Blog |
  Dashboard > WebWork2文档中文化计划 > ... > Interceptors > Conversion Error Interceptor
  WebWork2文档中文化计划 Log In View a printable version of the current page.  
  Conversion Error Interceptor
Added by 黑灵, last edited by scud on May 19, 2006  (view change)
Labels: 
(None)

要全面地了解这个拦截器,最好查看一下这个拦截器的子类(译者注:原文中是subclass,但是应该是父类)ConversionErrorInterceptor的JavaDocs:

这个拦截器把在ActionContext的conversionErrors Map中找到的所有错误添加为fieldError(action需要实现ValidationAware接口)。同时把有验证错误的field的原始值被保存下来,这样任何后面对于这个值的请求得到的都是原始值而不是action中的值。这一点很重要,因为如果值"abc"被提交了,但是它不能被转型为int,我们希望显示回来的是原来的"abc",而不是一个int值(像0,这样的值不易被用户察觉是输入错误了)

再来看看拦截器WebWorkConversionErrorInterceptor自己的JavaDocs:

它继承于ConversionErrorInterceptor,但是仅仅是在field值不是Null,或者不是"",或者不是{""}(只有一个元素的字符串数组,并且这个元素还是个空字符串)的情况下把转型错误从ActionContext加到Action的fieldErrors中。详细信息查看ConversionErrorInterceptor和类型转换文档.

参数

扩展

例子

<action name="someAction" class="com.examples.SomeAction">
 <interceptor-ref name="params"/>
 <interceptor-ref name="conversionError"/>
 <result name="success">good_result.ftl</result>
 </action>
Site running on a free Atlassian Confluence Open Source Project License granted to WebWork China. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.3 Build:#808 May 29, 2007) - Bug/feature request - Contact Administrators