当前位置:网站首页>表单传递时,如何隐式将值传过去
表单传递时,如何隐式将值传过去
2022-07-04 14:57:00 【抗争的小青年】
表单传递时,如何隐式将值传过去。
案例说明
- 出现在修改表单元素的时候,点击修改按钮时,需要发出get请求,以便在一会弹出的表单中进行展示(用户体验好)。
- 前台传给后端的请求方式是get请求,并传给一值id用来查询数据库相应表中,id为该值的所有字段并返回给前台,前台再将需要的字段渲染给页面。
- 当用户在弹出框中进行修改后,再将数据提交给后台去接口,后台接口接受到数据后,执行数据库语句,完成数据更新。
难点
解决的问题出现在第二步,也就是数据修改,并将数据传回后台。这时问题来了,数据库怎么知道你要修改的是那条数据呢?你弹出框form表单提交的只是修改的值,没有给id呀。
这个时候,在第一步中,我们已经将数据中的属性都查出来了,为什么不传个id呢?
啥? 你说你不想让用户修改id(主键)? 哦,这好办。我们可以在表单中再加一个标签,而且值也预先设定好,就是你要修改那条数据对应的数据库的id(主键),但是我们不给用户展示,我们把它隐藏起来。哎,就是玩!
这时候再提交数据的时候,里面就有id(主键)了,问题解决。
这里给大家提供一种解决办法的思路,如果有更好的办法,欢迎留言交流。
边栏推荐
- Research Report on surgical otorhinolaryngology equipment industry - market status analysis and development prospect prediction
- The vscode waveform curve prompts that the header file cannot be found (an error is reported if the header file exists)
- What is the catalog of SAP commerce cloud
- ~88 running people practice
- Can I "reverse" a Boolean value- Can I 'invert' a bool?
- Model fusion -- stacking principle and Implementation
- c# 实现定义一套中间SQL可以跨库执行的SQL语句
- Cut! 39 year old Ali P9, saved 150million
- ONgDB图数据库与Spark的集成
- [North Asia data recovery] a database data recovery case where the disk on which the database is located is unrecognized due to the RAID disk failure of HP DL380 server
猜你喜欢

How to decrypt worksheet protection password in Excel file
![[North Asia data recovery] a database data recovery case where the disk on which the database is located is unrecognized due to the RAID disk failure of HP DL380 server](/img/79/3fab19045e1ab2f5163033afaa4309.jpg)
[North Asia data recovery] a database data recovery case where the disk on which the database is located is unrecognized due to the RAID disk failure of HP DL380 server

Principle and general steps of SQL injection

Stress, anxiety or depression? Correct diagnosis and retreatment

The new generation of domestic ORM framework sagacity sqltoy-5.1.25 release
![[tutorial] yolov5_ DeepSort_ The whole process of pytoch target tracking and detection](/img/a7/92d670776e3fd3d5add3aa144617c7.jpg)
[tutorial] yolov5_ DeepSort_ The whole process of pytoch target tracking and detection

Audio and video technology development weekly | 252
![[native JS] optimized text rotation effect](/img/50/3c09f223e821c14e7e9e0fb47622b6.jpg)
[native JS] optimized text rotation effect

MySQL learning notes - data type (2)

DIY a low-cost multi-functional dot matrix clock!
随机推荐
Intranet penetrating FRP: hidden communication tunnel technology
Market trend report, technical innovation and market forecast of China's hair repair therapeutic apparatus
I let the database lock the table! Almost fired!
基于check-point机制的任务状态回滚和数据分块任务
Redis' optimistic lock and pessimistic lock for solving transaction conflicts
Statistical learning: logistic regression and cross entropy loss (pytoch Implementation)
Principle and general steps of SQL injection
MySQL learning notes - data type (2)
std::shared_ ptr initialization: make_ shared< Foo> () vs shared_ ptr< T> (new Foo) [duplicate]
APOC自定义函数和过程
2021 Google vulnerability reward program review
Stew in disorder
Audio and video technology development weekly | 252
Digital recognition system based on OpenCV
China's roof ladder market trend report, technological innovation and market forecast
~88 running people practice
Interpretation of the champion scheme of CVPR 2020 night target detection challenge
Big God explains open source buff gain strategy live broadcast
多年锤炼,迈向Kata 3.0 !走进开箱即用的安全容器体验之旅| 龙蜥技术
Oracle监听器Server端与Client端配置实例