关于charset,使用#form#和#getHttpRequestData()#有什么区别?

时间:2012-06-01 15:58:04

标签: http coldfusion localhost

我有一个coldfusion页面,uni.cfm:

<cfprocessingdirective pageencoding="utf-8">
<cfscript>

<cfdump var="#form.a#" label="form">
<cfdump var="#getHttpRequestData().content#" label="form2">

发送以下HTTP请求首先在返回的html中生成字符串"???",然后生成字符串"a=ΠΣΩ"

POST http://localhost:8080/uni/unicode.cfm HTTP/1.1
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
User-Agent: unicli
Host: localhost:8080
Content-Length: 8
Pragma: no-cache

a=ΠΣΩ

为什么#form.a#NOT正确处理二进制字符串,而getHttpRequestData()呢?

1 个答案:

答案 0 :(得分:2)

让发件人将内容类型更改为multipart/form-data,并且没有网址编码就像魅力一样:

POST *URL* HTTP/1.1
Content-Type: multipart/form-data; boundary=AaB03x
Content-Length: 145

--AaB03x
Content-Disposition: form-data; name="a"

ΠΣΩ
--AaB03x--

然后能够使用#form.a#并获得正确的字符串!