先检查获取的字段名和 name中的值是否相符
一、
检查 name属性中有没有空格
如:<input name="name id">
可能会导致无法获取。
二、
把name值改成短值测试(很诡异)
同学代码本来是
<input type="text" name="Product id"/>
运行失败!
头一次改成
<input type="text" name="Productid"/>
还是失败!
二改小写:
<input type="text" name="productid"/>
失败!
三改短值:
<input type="text" name="p"/>
虽然报了其他错误但并没有提示“p字段为空”。
四、五改改回去又不报错了
不管是:
<input type="text" name="Productid"/>
还是:
<input type="text" name="productid"/>
又都不报错了。
当时就懵了,有知道的说一下原理吧。