php文本框的属性,form表单提交中文本框属性disabled与readOnly区别

本文探讨了HTML表单中GET和POST提交方式的区别,特别是它们在处理数据编码和中文乱码问题上的差异。GET方式会将参数显示在URL后面,适合无副作用的请求,而POST方式将数据包含在请求体中,适用于可能修改数据的情况。当使用GET方式处理包含中文的数据时,可能会出现乱码问题,而POST则能更好地处理Unicode字符。了解这些差异对于避免编码错误和确保数据正确传输至关重要。
摘要由CSDN通过智能技术生成

e05ede28b14bd8741b6152c1fe727c15.png

今天碰到一个问题,当把一个input控件设置成disabled,发现form提交并把此值提交到后台,导致后台逻辑出现“未将对象引用设置到实例”的错,当把disabled改成readOnly后发现一切OK了,从中,我们也就知道disabeled与readOnly的一个区别了。

今天无意中看了一下W3C文档,看了一下form提交的post与get方法的区别,还是先看原文吧:

17.13.1 Form submission method

The method attribute of the FORM element specifies the HTTP method used to send the form to the processing agent. This attribute may take two values:

get: With the HTTP "get" method, the form data set is appended to the URI specified by the action attribute (with a question-mark ("?") as separator) and this new URI is sent to the processing agent.

post: With the HTTP "post" method, the form data set is included in the body of the form and sent to the processing agent.

The "get" method should be used when the form is idempotent (i.e., causes no side-effects). Many database searches have no visible side-effects and make ideal applications for the "get" method.

If the service associated with the processing of a form causes side effects (for example, if the form modifies a database or subscription to a service), the "post" method should be used.

Note. The "get" method restricts form data set values to ASCII characters. Only the "post" method (with enctype="multipart/form-data") is specified to cover the entire [ISO10646] character set.

大致意思是:form提交的默认方式是“get”,get与set的区别:用get方式提交form表单时,会将参数跟在url后提交到后台处理,就是我们常见的?参数名=参数值的形式。并且会用ACSII码来编码参数以及参数值。post方式提交form表单时,不是在url后拖带参数,而是将数据内容带在form表单里一起提交到后台处理,这样数据不会被加密(只有当form的enctype="multipart/form-data"时,post提交才会用ISO10646来加密内容)。

上面几句话在我们的实际运用中有什么作用呢?那就是在诸多场景中的中文乱码的问题!当我们忘了给form表单设置form的method时(默认是get),会莫名其妙的出现一些中文乱码的问题,包括后台获取参数值时。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值