有关URLEncoder和URLDecoder的一些问题?

编程入门 行业动态 更新时间:2024-10-24 22:29:10
本文介绍了有关URLEncoder和URLDecoder的一些问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我已经通过了URLEncoder和URLDecoder的javadocs。然后更好奇在任何web应用程序中,每当我们提交表单时,服务器将表单字段转换为urlencoded字段,当我们执行request.getParamter(fieldName)时。服务器再次使用URLDecoder进行解码。 是否正确?服务器是做这个还是浏览器?当我们在地址栏中输入任何url时,会发生同样的事情吗? 如果服务器或浏览器在URLEncoder和URLDecoder的帮助下明确地编码或解码请求参数,那么?虽然这些是基本问题,但是找不到这些清楚。 / p>

解决方案

在任何web应用程序中,只要我们提交表单,服务器将表单域转换为urlencoded字段,我们请request.getParamter(fieldName)。

否。浏览器会这样做。

服务器再次使用URLDecoder进行解码。这是正确的吗?

服务器是做还是浏览器?

浏览器。

如果我们需要在URLEncoder和URLDecoder的帮助下明确地对请求参数进行编码或解码,那么服务器或浏览器是否这样做?'

我不知道这是什么意思,但它仍然是浏览器。如果从应用程序代码发送请求,则只需要对请求参数进行编码。如果你正在运行一个servlet容器,你根本不需要解码它们:它会为你做的。

I have gone thru javadocs of URLEncoder and URLDecoder. Then got more inquisitive. Consider the server as tomcat.In any webapplication whenever we submit the form , server converts the forms fields into urlencoded fields and when we do request.getParamter("fieldName"). Server again decode it with URLDecoder. Is that correct? Does server do it or browser? Simlary when we type any url in address bar same stuff happens? If server or browser does that when we require to encode or decode the request paramter explicitly with the help of URLEncoder and URLDecoder? Though these are basic questions but could not find these anwers clearly.

解决方案

In any webapplication whenever we submit the form , server converts the forms fields into urlencoded fields and when we do request.getParamter("fieldName").

No. The browser does that.

Server again decode it with URLDecoder. Is that correct?

Yes.

Does server do it or browser?

The browser.

If server or browser does that when we require to encode or decode the request parameter explicitly with the help of URLEncoder and URLDecoder?'

I don't know what that means but it's still the browser. You only need to encode the request parameters if you are sending the request from application code. You don't need to decode them at all if you're running in a servlet container: it will do that for you.

更多推荐

有关URLEncoder和URLDecoder的一些问题?

本文发布于:2023-10-28 17:57:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1537365.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:URLEncoder   URLDecoder

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!