@Test public void getUserByName() throws Exception { String name="longzhiran"; String sql = "SELECT * FROM user WHERE USERNAME = ?"; List<User> list = jdbcTemplate.query(sql, new User(), new Object[]{name}); for (User user : list) { System.out.println(user); } }
@GetMapping("getUserByName") public List getUserByName(String userName)throws Exception { String sql = "SELECT * FROM user WHERE USERNAME = ?"; List<User> list = jdbcTemplate.query(sql, new User(), new Object[]{userName}); return list; }
UserController { @GetMapping("getUserByName") public List getUserByName(String userName)throws Exception { String sql = "SELECT * FROM user WHERE USERNAME = ?"; List<User> list = jdbcTemplate.query(sql, new User(), new Object[]{userName}); return list; } }
UserController { @GetMapping("getUserByName") public List getUserByName(String userName)throws Exception { String sql = "SELECT * FROM user WHERE USERNAME = ?"; List<User> list = jdbcTemplate.query(sql, new User(), new Object[]{userName}); return list; }  }
UserController { @GetMapping("getUserByName") public List getUserByName(String userName)throws Exception { String sql = "SELECT * FROM user WHERE USERNAME = ?"; List<User> list = jdbcTemplate.query(sql, new User(), new Object[]{userName}); return list; }  @GetMapping("createUserTable") String createUserTable(); @GetMapping("saveUserTest") String saveUserTest(); @GetMapping("batchSave") String batchSaveUser(); @GetMapping("add") String addUser(String userName, String passWord); @GetMapping("updateUserPassword") String updateUserPassword(int id, String passWord); @GetMapping("deleteUserById") String deleteUserById(int id); @GetMapping("getUserByName") List getUserByName(String userName); @GetMapping("getMapById") Map getMapById(Integer id); @GetMapping("getUserById") User getUserById(Integer id); @GetMapping("list") List<User> list(); }
UserController { @GetMapping("getUserByName") public List getUserByName(String userName)throws Exception { String sql = "SELECT * FROM user WHERE USERNAME = ?"; List<User> list = jdbcTemplate.query(sql, new User(), new Object[]{userName}); return list; }  @GetMapping("createUserTable") String createUserTable(); @GetMapping("saveUserTest") String saveUserTest(); @GetMapping("batchSave") String batchSaveUser(); @GetMapping("add") String addUser(String userName, String passWord); @GetMapping("updateUserPassword") String updateUserPassword(int id, String passWord); @GetMapping("deleteUserById") String deleteUserById(int id); @GetMapping("getUserByName") List getUserByName(String userName); @GetMapping("getMapById") Map getMapById(Integer id); @GetMapping("getUserById") User getUserById(Integer id); @GetMapping("list") List<User> list();  }