PostMethod setRequestBody(String) deprecated - why?

后端 未结 2 840
-上瘾入骨i
-上瘾入骨i 2020-12-09 15:31

I am using Apache Commons HttpClient PostMethod 3.1.

In the PostMethod class there are also three methods for setting POST method\'s request body:

se         


        
相关标签:
2条回答
  • 2020-12-09 15:58

    The javadoc says:

    Deprecated. use setRequestEntity(RequestEntity)

    RequestEntity has a lot of implementors, namely:

    ByteArrayRequestEntity, FileRequestEntity, InputStreamRequestEntity, MultipartRequestEntity, StringRequestEntity

    Use the one that suits you:

    • if your xml is in a String, use the StringRequestEntity
    • if it is in a file, use the FileRequestEntity

    and so on.

    0 讨论(0)
  • 2020-12-09 16:09

    Yes, so for example,

    post.setRequestEntity( new StringRequestEntity( xml ) );
    

    instead of

    post.setRequestBody( xml );
    
    0 讨论(0)
提交回复
热议问题