ZBLOG

//更新电影 @RequestMapping(value = "/updateMovie") @ResponseBody @Transactional public String updateMovie(int id,String name,String actorName,String date,String introduce,String picture) { movieService.updateMovie(id,nam

在HTML网页中,您可以使用AJAX或表单提交来调用该方法并修改数据库中的数据。下面是一个示例:

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Update Movie</title>
  5. <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  6. <script>
  7. function updateMovie() {
  8. var id = parseInt($("#movieId").val());
  9. var name = $("#movieName").val();
  10. var actorName = $("#actorName").val();
  11. var date = $("#releaseDate").val();
  12. var introduce = $("#introduce").val();
  13. var picture = $("#pictureURL").val();
  14. $.ajax({
  15. url: "/updateMovie",
  16. type: "POST",
  17. data: {
  18. id: id,
  19. name: name,
  20. actorName: actorName,
  21. date: date,
  22. introduce: introduce,
  23. picture: picture
  24. },
  25. success: function(response) {
  26. alert(response);
  27. },
  28. error: function(xhr, status, error) {
  29. console.log(error);
  30. }
  31. });
  32. }
  33. </script>
  34. </head>
  35. <body>
  36. <h1>Update Movie</h1>
  37. <label for="movieId">Movie ID:</label>
  38. <input type="text" id="movieId"><br>
  39. <label for="movieName">Movie Name:</label>
  40. <input type="text" id="movieName"><br>
  41. <label for="actorName">Actor Name:</label>
  42. <input type="text" id="actorName"><br>
  43. <label for="releaseDate">Release Date:</label>
  44. <input type="text" id="releaseDate"><br>
  45. <label for="introduce">Introduce:</label><br>
  46. <textarea id="introduce"></textarea><br>
  47. <label for="pictureURL">Picture URL:</label>
  48. <input type="text" id="pictureURL"><br>
  49. <button onclick="updateMovie()">Update</button>
  50. </body>
  51. </html>

请确保将/updateMovie的URL和请求方法与后端的路由一致,并使用正确的请求类型(POST或GET)进行调用。在成功更新数据库后,会弹出一个提示框显示 “update success”。


内容由零声教学AI助手提供,问题来源于学员提问

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:https://golang.0voice.com/?id=10173

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?