当前位置:网站首页>表单传递时,如何隐式将值传过去
表单传递时,如何隐式将值传过去
2022-07-04 14:57:00 【抗争的小青年】
表单传递时,如何隐式将值传过去。
案例说明
- 出现在修改表单元素的时候,点击修改按钮时,需要发出get请求,以便在一会弹出的表单中进行展示(用户体验好)。
- 前台传给后端的请求方式是get请求,并传给一值id用来查询数据库相应表中,id为该值的所有字段并返回给前台,前台再将需要的字段渲染给页面。
- 当用户在弹出框中进行修改后,再将数据提交给后台去接口,后台接口接受到数据后,执行数据库语句,完成数据更新。
难点
解决的问题出现在第二步,也就是数据修改,并将数据传回后台。这时问题来了,数据库怎么知道你要修改的是那条数据呢?你弹出框form表单提交的只是修改的值,没有给id呀。
这个时候,在第一步中,我们已经将数据中的属性都查出来了,为什么不传个id
呢?
啥? 你说你不想让用户修改id(主键)? 哦,这好办。我们可以在表单中再加一个标签,而且值也预先设定好,就是你要修改那条数据对应的数据库的id(主键),但是我们不给用户展示,我们把它隐藏起来。哎,就是玩!
这时候再提交数据的时候,里面就有id(主键)了,问题解决。
这里给大家提供一种解决办法的思路,如果有更好的办法,欢迎留言交流。
边栏推荐
- 《吐血整理》保姆级系列教程-玩转Fiddler抓包教程(2)-初识Fiddler让你理性认识一下
- Principle and general steps of SQL injection
- China's plastic processing machinery market trend report, technological innovation and market forecast
- I let the database lock the table! Almost fired!
- Statistical learning: logistic regression and cross entropy loss (pytoch Implementation)
- Will the memory of ParticleSystem be affected by maxparticles
- [book club issue 13] packaging format and coding format of audio files
- Socks agent tools earthworm, ssoks
- Market trend report, technical innovation and market forecast of tetrabromophthalate (pht4 diol) in China
- Web components series - detailed slides
猜你喜欢
The 17 year growth route of Zhang Liang, an open source person, can only be adhered to if he loves it
[tutorial] yolov5_ DeepSort_ The whole process of pytoch target tracking and detection
error: ‘connect‘ was not declared in this scope connect(timer, SIGNAL(timeout()), this, SLOT(up
[North Asia data recovery] a database data recovery case where the partition where the database is located is unrecognized due to the RAID disk failure of HP DL380 server
AI system content recommendation issue 24
MySQL learning notes - data type (2)
[hcie TAC] question 5 - 1
Qt---error: ‘QObject‘ is an ambiguous base of ‘MyView‘
多年锤炼,迈向Kata 3.0 !走进开箱即用的安全容器体验之旅| 龙蜥技术
Using celery in projects
随机推荐
Understand asp Net core - Authentication Based on jwtbearer
How to save the contents of div as an image- How to save the contents of a div as a image?
Logstash ~ detailed explanation of logstash configuration (logstash.yml)
Interface fonctionnelle, référence de méthode, Widget de tri de liste implémenté par lambda
《吐血整理》保姆级系列教程-玩转Fiddler抓包教程(2)-初识Fiddler让你理性认识一下
. Net delay queue
Sql实现Split
Interpretation of the champion scheme of CVPR 2020 night target detection challenge
Market trend report, technical innovation and market forecast of taillight components in China
After the eruption of Tonga volcano, we analyzed the global volcanic distribution and found that the area with the most volcanoes is here!
PR FAQ: how to set PR vertical screen sequence?
Filtered off site request to
Model fusion -- stacking principle and Implementation
Accounting regulations and professional ethics [10]
~88 running people practice
[North Asia data recovery] a database data recovery case where the partition where the database is located is unrecognized due to the RAID disk failure of HP DL380 server
[book club issue 13] coding format of video files
Review of Weibo hot search in 2021 and analysis of hot search in the beginning of the year
MySQL learning notes - data type (2)
Daily notes~