doutang3760 2015-03-17 11:12
浏览 131
已采纳

如何发送带空格的POST请求?

I'm trying to send input from an edittext to PHP. If I send in something with no spaces it works ok, but crashes with spaces and says this:

illegal character

...which refers to the space.

Obviously it's a matter of getting the quotes correct but for some reason I just can't get this right.

Where do I add the quotes?

Is it in Java during creating the URL?

http://example.com/android/project_group_notes_details.php?course=\'"+sessionCourse+"\'";

or while creating the Variable?

String sessionCouse = "\'Software Development With Spaces\'";

or is it somehow done server side?

  • 写回答

2条回答 默认 最新

  • dongyi1748 2015-03-17 11:29
    关注

    A standard browser takes any spaces entered into the address bar and replaces them with %20; HTML's space character.

    HTTP does not do this, the browser does, meaning that you have two options:

    1. Create a function to take in a string and replace all spaces with %20;
    2. Manually replace spaces with %20

    For example:

    String sessionCouse = "\'Software Development With Spaces\'";
    

    should actually be

    String sessionCouse = "\'Software%20Development%20With%20Spaces\'";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?