开发者

Java HTTP Get Request

I need to make one HTTP GET Request to a Java Web Service: I'm making this request:

http://127.0.0.1:8080/MyService/services/service?method=myMethod&a=&b=test&startDate=2011-03-10 10:00&endDate=2011-03-10 19:00

When I Debug my app the parameters come w开发者_运维问答ith the values switched. I already tried to encode the startDate and endDate parameters but the result is the same.

What am i doing wrong?


You should encode your URLs so they don't contain spaces. This could be your problem. See http://download.oracle.com/javase/1.5.0/docs/api/java/net/URLEncoder.html


As @Mirkules says, you should encode the spaces and colons in the parameter values ... even if you don't think it makes any difference!

Apart from that, maybe your servlet code is expecting Request.getParameters() to deliver the parameters in the order that they appear in the URL. This is not the case. If order of the parameters is significant, you need to parse the query string yourself. (Or consider fixing your web API so that the query parameter order is irrelevant.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜