WebWork 2.2.2中文上传乱码问题[临时解决方案]

使用jakarta commons-upload。
升级到2.2.2后发现上传中文会乱码。
经过跟踪发现在com.opensymphony.webwork.dispatcher.DispatcherUtils的prepare(HttpServletRequest request, HttpServletResponse response)方法。
2.2.1->2.2.2时这个方法发生了非常的的变化。
2.2.1时: 
public   void  prepare(HttpServletRequest request, HttpServletResponse response) { 
        
if  (encoding  !=   null ) { 
            
try  { 
                request.setCharacterEncoding(encoding); 
            } 
catch  (Exception e) { 
                LOG.error(
" Error setting character encoding to ' "   +  encoding  +   " ' - ignoring. " , e); 
            } 
        } 

        
if  (locale  !=   null ) { 
            response.setLocale(locale); 
        } 

        
if  (paramsWorkaroundEnabled) { 
            request.getParameter(
" foo " );  //  simply read any parameter (existing or not) to "prime" the request 
        } 
    }

2.2.2时:
public   void  prepare(HttpServletRequest request, HttpServletResponse response) { 
        String encoding 
=   null
        
if  (Configuration.isSet(WebWorkConstants.WEBWORK_I18N_ENCODING)) { 
            encoding 
=  Configuration.getString(WebWorkConstants.WEBWORK_I18N_ENCODING); 
        } 

        Locale locale 
=   null
        
if  (Configuration.isSet(WebWorkConstants.WEBWORK_LOCALE)) { 
            locale 
=  LocalizedTextUtil.localeFromString(Configuration.getString(WebWorkConstants.WEBWORK_LOCALE), request.getLocale()); 
        } 

        
if  (encoding  !=   null   &&   ! MultiPartRequest.isMultiPart(request)) { 
            
try  { 
                request.setCharacterEncoding(encoding); 
            } 
catch  (Exception e) { 
                LOG.error(
" Error setting character encoding to ' "   +  encoding  +   " ' - ignoring. " , e); 
            } 
        } 

        
if  (locale  !=   null ) { 
            response.setLocale(locale); 
        } 

        
if  (paramsWorkaroundEnabled) { 
            request.getParameter(
" foo " );  //  simply read any parameter (existing or not) to "prime" the request 
        } 
    }


我看了jira没有发现encoding != null && !MultiPartRequest.isMultiPart(request)这个判断的意义。但是它会造成对multiPartRequest的encoding判断失败,中文就会乱码。
所以临时的解决方案是将判断改成:
if (encoding != null)

听说WW的Jira已经不接受新issue了,不知是否真的? Crying or Very sad
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值