浏览 1501 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2011-08-12
最后修改:2011-08-12
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. 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |