Blogger Information
Blog 110
fans 0
comment 0
visits 112277
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Springboot+Mybatis+Thymeleaf增加数据的简单示例
Coco
Original
454 people have browsed it

  1、

  /gqsi/src/main/resources/mapping/UserMpping.xml

  

  insert into user(userName,passWord) values(#{userName},#{passWord})

  

  2、

  /gqsi/src/main/java/com/gl/mapper/UserMapper.java

  int insertUser(User user);

  3、

  /gqsi/src/main/java/com/gl/service/UserService.java

  public int insertUser(User user) {

  return userMapper.insertUser(user);

  }

  4、

  /gqsi/src/main/java/com/gl/controller/UserController.java

  @PostMapping("/useradd")

  public String addUser(User user) {

  System.out.println(user);

  int res=userService.insertUser(user);

  // 重定向到列表页面

  // redirect:表示重定向到一个地址

  // forward:表示转发到一个地址

  return "redirect:/userlist";

  }

  5、

  /gqsi/src/main/resources/templates/useradd.html

  

  用户名:

  密码:

  

  

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post