Java#Servlet规范#HTTP Protocol Parameters

Java#Servlet规范#HTTP Protocol Parameters

场景

异构系统服务调用,约定传递xml结构数据,服务逻辑使用getInputStream获取数据并进行逻辑处理,后续由于服务的统一入口逻辑变更增加request parameter操作造成传递的结构数据被安全过滤和转义,进而影响到后续服务逻辑处理。

原因

服务调用方传递的contentTypeapplication/x-www-form-urlencoded依据servlet规则会自动组装到request parameter中。

Servlet规范约定了传递到Servlet的数据填充到request.getParameter集合的规则,在与异构系统通信时如果没有明确约束会增加很多调试沟通成本。

资料

一、servlet-2_4-fr-spec.pdf

二、SRV.4.1.1 When Parameters Are Available

The following are the conditions that must be met before post form data will be populated to the parameter set:

1. The request is anHTTP or HTTPS request.

2. The HTTP method is POST.

3. The content type is application/x-www-form-urlencoded.

 4. The servlet has made an initial call of any of the getParameter family of methods on the request object.

If the conditions are not met and the post form data is not included in the parameter set, the post data must still be available to the servlet via the request object’s input stream. If the conditions are met, post form data will no longer be available for reading directly from the request object’s input stream.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值