有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (1) 个答案

  1. # 1 楼答案

    Will our web server misunderstood the symbol and change it back to space?

    否,因为在表单中输入+字符时,它会被编码为%2B

    下面是一个例子(fiddle):

    <form method="POST" action="/">
        <input name="foo" type="text" value="+">
        <input name="bar" type="text" value="bacon sauce">
    </form>
    
    <script>
        // This encodes the form, (i.e. that's what your server receives)
        alert( $('form').serialize() );
    </script>
    

    警报框将显示:foo=%2B&bar=bacon+sauce

    这意味着+被编码为%2B。因此,在服务器上,只需将所有+字符转换为space,将%2B转换为+,但您可能应该将解码部分留给框架或库。 ​

    这里有一把小提琴可以用来演奏参数编码:fiddle