使用jsp将数据库中的自动增量id显示到html文本字段中

gajydyqb  于 2021-06-25  发布在  Mysql
关注(0)|答案(1)|浏览(321)

这个问题在2016年早些时候被问到,但问这个问题的人没有得到答案。所以有人知道如何得到这个id,这已经是人工智能,但我需要它自动显示在一个html格式。因此,我插入了一个新的用户仍然没有分配id。

<h3>Kreirati korisnika</h3>
    <form action="kreiraj_korisnika.jsp">
      <div class="form-group" >
        <label for="id_clan" >ID:</label>
        <input type="text" class="form-control" id="id_clan" name="id_clan">
      </div>
xggvc2p6

xggvc2p61#

首先,您必须获得下一个可能的id。请检查以下说明:
https://dev.mysql.com/doc/refman/8.0/en/getting-unique-id.html
然后您可以处理数据:
文本框:

<input type="text" class="form-control" id="id_clan" name="id_clan" value="<%= yourId%>"/>

jsp代码:

<%! String yourId; %>
<%
  //do some code to receive your data
  yourId="YOUR_ID";
%>

请参阅此处以获取更多信息:从jsp为html文本框赋值

https://www.quora.com/how-do-i-pass-the-text-entered-into-an-html-text-box-to-a-java-method-if-i-am-using-jsp

相关问题