当前位置:网站首页>表单传递时,如何隐式将值传过去
表单传递时,如何隐式将值传过去
2022-07-04 14:57:00 【抗争的小青年】
表单传递时,如何隐式将值传过去。
案例说明
- 出现在修改表单元素的时候,点击修改按钮时,需要发出get请求,以便在一会弹出的表单中进行展示(用户体验好)。
- 前台传给后端的请求方式是get请求,并传给一值id用来查询数据库相应表中,id为该值的所有字段并返回给前台,前台再将需要的字段渲染给页面。
- 当用户在弹出框中进行修改后,再将数据提交给后台去接口,后台接口接受到数据后,执行数据库语句,完成数据更新。
难点
解决的问题出现在第二步,也就是数据修改,并将数据传回后台。这时问题来了,数据库怎么知道你要修改的是那条数据呢?你弹出框form表单提交的只是修改的值,没有给id呀。
这个时候,在第一步中,我们已经将数据中的属性都查出来了,为什么不传个id
呢?
啥? 你说你不想让用户修改id(主键)? 哦,这好办。我们可以在表单中再加一个标签,而且值也预先设定好,就是你要修改那条数据对应的数据库的id(主键),但是我们不给用户展示,我们把它隐藏起来。哎,就是玩!
这时候再提交数据的时候,里面就有id(主键)了,问题解决。
这里给大家提供一种解决办法的思路,如果有更好的办法,欢迎留言交流。
边栏推荐
- Stress, anxiety or depression? Correct diagnosis and retreatment
- [Previous line repeated 995 more times]RecursionError: maximum recursion depth exceeded
- . Net delay queue
- ECCV 2022放榜了:1629篇论文中选,录用率不到20%
- Stew in disorder
- CMPSC311 Linear Device
- [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
- Redis: SDS source code analysis
- Research Report on market supply and demand and strategy of surgical stapler industry in China
- Understand asp Net core - Authentication Based on jwtbearer
猜你喜欢
error: ‘connect‘ was not declared in this scope connect(timer, SIGNAL(timeout()), this, SLOT(up
Unity animation day05
Overview of convolutional neural network structure optimization
Redis' optimistic lock and pessimistic lock for solving transaction conflicts
@EnableAspectAutoJAutoProxy_ Exposeproxy property
Hidden communication tunnel technology: intranet penetration tool NPS
Vscode prompt Please install clang or check configuration 'clang executable‘
《吐血整理》保姆级系列教程-玩转Fiddler抓包教程(2)-初识Fiddler让你理性认识一下
Interface test - knowledge points and common interview questions
Application of clock wheel in RPC
随机推荐
Summary of database 2
[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
ECCV 2022放榜了:1629篇论文中选,录用率不到20%
对人胜率84%,DeepMind AI首次在西洋陆军棋中达到人类专家水平
Accounting regulations and professional ethics [7]
L1-072 scratch lottery
[Chongqing Guangdong education] National Open University spring 2019 1248 public sector human resource management reference questions
同构图与异构图CYPHER-TASK设计与TASK锁机制
One question per day 540 A single element in an ordered array
c# 实现定义一套中间SQL可以跨库执行的SQL语句
How to save the contents of div as an image- How to save the contents of a div as a image?
线程池的使用和原理
MFC implementation of ACM basic questions encoded by the number of characters
Selenium element interaction
China tall oil fatty acid market trend report, technical dynamic innovation and market forecast
[flask] ORM one to many relationship
Qt---error: ‘QObject‘ is an ambiguous base of ‘MyView‘
China's roof ladder market trend report, technological innovation and market forecast
Hair growth shampoo industry Research Report - market status analysis and development prospect forecast
After the eruption of Tonga volcano, we analyzed the global volcanic distribution and found that the area with the most volcanoes is here!