代码回顾-request

webx3中(wdetail)处理淘客的一个pipeline

@Autowired
    private HttpServletRequest request;
 
    @Override
    public void invoke(final PipelineContext pipelineContext) throws Exception {
       final String ttid = request.getParameter(RUNDATA_SPID);
       final String pid = ttidMappingPid.get(ttid);
       if (StringUtils.isNotBlank(pid)) {
           request.getParameterMap().put(TK_PID_PREFIX, pid);
           request.getParameterMap().put(TK_APP_ID, "12003897");
        }
pipelineContext.invokeNext();
    }
 

请仔细的看一下,该代码有什么问题没?

 

有,request.getParameterMap().put(TK_PID_PREFIX, pid);会抛异常的。。。

 java.lang.UnsupportedOperationException

        at java.util.AbstractMap.put(AbstractMap.java:186)

        at

 

request.getParameterMap() 这里返回的是一个 com.alibaba.citrus.service.requestcontext.parser.impl.ParserRequestContextImpl$ParameterMap

 

private class ParameterMap extends AbstractMap<String, String[]> {

 

     */

    public V put(K key, V value) {

    throw new UnsupportedOperationException();

}

 

修改方法:

rundata.getParameters().add(key, value)

rundata.getParameters()返回的是com.alibaba.citrus.service.requestcontext.parser.impl.ParameterParserImpl   有对应的params操作。。

 

回头看了看httpserlet.getParameterMap

java.util.Map getParameterMap()

Returns a java.util.Map of the parameters of this request. Request parameters are extra information sent with the request. For HTTP servlets, parameters are contained in the query string or posted form data.

Returns:

an immutable java.util.Map containing parameter names as keys and parameter values as map values. The keys in the parameter map are of type String. The values in the parameter map are of type String array.

所以很明显,我们的webx在这一点上还是很尊重servlet规范的

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值