我怎么能发送带有空格的POST请求? [英] How can I send a POST request with spaces?
问题描述
我想从一个EditText到PHP输入发送。如果我的东西,没有空格它工作正常发送,但空格崩溃,这样说:
非法字符
块引用>...其指的空间。
显然,这是获得正确的报价,但由于某种原因,我不能得到这个权利的问题。
我在哪里可以加引号?
创建URL时它是在Java中?
<$p$p><$c$c>http://example.com/android/project_group_notes_details.php?course=\\'\"+sessionCourse+\"\\'\";
或在创建变量?
字符串sessionCouse =\\'软件开发空间\\';
或以某种方式做服务器端?
解决方案一个标准的浏览器需要任何空格输入到地址栏和
20%
替换他们。 HTML的空格
字符。HTTP不这样做,浏览器,这意味着你有两种选择:
- 创建一个函数来采取一个字符串,替换所有的空格
20%
;- 手动替换用空格
20%
例如:
字符串sessionCouse =\\'软件开发空间\\';
实际上应该是
字符串sessionCouse =\\'软件%20Development%20With%20Spaces \\';
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?
解决方案A standard browser takes any spaces entered into the address bar and replaces them with
%20
; HTML'sspace
character.HTTP does not do this, the browser does, meaning that you have two options:
- Create a function to take in a string and replace all spaces with
%20
;- Manually replace spaces with
%20
For example:
String sessionCouse = "\'Software Development With Spaces\'";
should actually be
String sessionCouse = "\'Software%20Development%20With%20Spaces\'";
这篇关于我怎么能发送带有空格的POST请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!