html - 提交的表格未编码 +'s when using method="get"

标签 html forms

用下面的形式

<form target="dialogiframe" action="ConfigUpdate.cvx" id="TestForm" 
    name="TestForm" method="get">
    <input name="test" type="text" size="40" value="A Sum 1+2=3"/>
    <input type="submit" value="Set" />
</form>

发送请求的参数编码如下

test=A+Sum+1+2=3

解码后,它给出了错误的值“A Sum 1 2=3”,因为参数中的 + 未编码(= 也未编码),并且它被转换为空格。

如果我将方法更改为发布,则参数将正确编码为

test=A+Sum+1%2B2%3D3

然后正确转换。

我知道我应该使用 POST 并且确实正在浏览我的页面并正在转换它们,但是我是否遗漏了表单定义中的任何内容以使 GET 编码正确?

用 IE8 和 FF10 测试,<!DOCTYPE html> 中的页面

最佳答案

我认为这是使用 GET 作为表单方法的一个已知问题。通常,您应该对表单使用 POST 方法。

发件人:http://www.cs.tut.fi/~jkorpela/forms/methods.html

The official recommendations say that "GET" should be used if and only if the form processing is idempotent, which typically means a pure query form. Generally it is advisable to do so. There are, however, problems related to long URLs and non-ASCII character repertoires which can make it necessary to use "POST" even for idempotent processing.

关于html - 提交的表格未编码 +'s when using method="get",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9582470/

相关文章:

javascript - iFrame 布局和滚动问题

javascript - 当输入字段具有特定值时,如何更改 div 的类?

php - 如何在php中查看mysql查询结果

javascript - 根据文本输入的值添加 <select> 选项

forms - 在没有 ngModel 的情况下将表单标记为脏(手动)

css - Bootstrap 表单组行不起作用

javascript - 将YouTube视频嵌入到iframe中

html - 每次我将鼠标悬停在按钮上时,我的文字和图像都会移动

php - 使用 POST 创建 HTML 表格

php - 在提交之前通过 Javascript 进行一些表单验证是否明智?