吐槽-httpservletrequest不支持getparameter真麻烦!

转自:http://www.hetaoblog.com/%E5%90%90%E6%A7%BD-httpservletrequest%E4%B8%BA%E4%BB%80%E4%B9%88%E5%AF%B9%E8%AF%B7%E6%B1%82body%E9%87%8C%E9%9D%A2%E7%9A%84%E4%B8%9C%E8%A5%BF%E4%B8%8D%E6%94%AF%E6%8C%81getparameter%E5%91%A2/
写servlet程序的时候,通过servletrequest.getparameter来获取内容呢?下面是这个api的说明,
就是说如果form的请求设定了enctype=”multipart/form-data”以后,请求的参数内容放到了请求body里面了,所以要读出来需要自己调用getinputstream或者getreader()的方式来调用,或者是借助于commons-fileupload来调用,这不折腾么?

提供一个bytes[] getParameter(String name)不就好了么?真麻烦!

String getParameter(String name)
Returns the value of a request parameter as a String, or null if the parameter does not exist. Request parameters are extra information sent with the request. For HTTP servlets, parameters are contained in the query string or posted form data.
You should only use this method when you are sure the parameter has only one value. If the parameter might have more than one value, use getParameterValues(java.lang.String).

If you use this method with a multivalued parameter, the value returned is equal to the first value in the array returned by getParameterValues.

If the parameter data was sent in the request body, such as occurs with an HTTP POST request, then reading the body directly via getInputStream() or getReader() can interfere with the execution of this method.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值