我需要能够使用 Javascript 指定如何在 Content-Type 标头中发布包含 enctype 作为“application/x-www-form-urlencoded”和 charset 作为“charset=UTF-8”的表单。有任何想法吗?
我有一个 Form 类型的 aForm 对象。
谢谢!
我需要能够使用 Javascript 指定如何在 Content-Type 标头中发布包含 enctype 作为“application/x-www-form-urlencoded”和 charset 作为“charset=UTF-8”的表单。有任何想法吗?
我有一个 Form 类型的 aForm 对象。
谢谢!
Last I checked, you simply can't rely on being told the charset of a form submit. Most sites either assume the charset (hopefully UTF-8 on modern sites) or they pass it in a separate query parameter.
Assuming that the charset will be something in particular isn't as crazy as it sounds. Every browser in common use will use the same encoding for submitting a form as the page that contained the form. So if you send the HTML page containing the form in UTF-8, you can pretty safely assume the submission will also be in UTF-8.
尝试.setRequestHeader( 'content-type', 'application/x-www-form-urlencoded;charset=UTF-8' );
“application/x-www-form-urlencoded”和utf-8不能一起使用。我也有“application/x-www-form-urlencoded”,在servlet的doPost方法中接受请求时尝试request.setCharacterEncoding(“UTF -8"); 经过大量搜索后为我工作的多语言字符