开发者

Reading browser's POST request content to Java

in my web page, there is a form that sends via POST request data to my web server. In my server (Java) i'm reading the request's content, but some characters are not being read well. For example, "=" turns into "%3D", ":" turns into "%3A" and " " turns into "+". How can I make my web server read these characters as 开发者_运维技巧they were written in the text box?

Thanks, Tomer


Those are the URL encoded versions of the characters.

If you are in a Servlet context and you simply do request.getParameter() you should automatically get the decoded (normal) versions.

If for some reason you aren't getting those, you can use java.net.URLDecoder.decode(input, "UTF-8"); to decode manually, but you might wanna do some root cause analysis to see why you are getting encoded stuff in the first place. Maybe your web form is doing double encoding?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜