|
@@ -2,6 +2,7 @@ package com.controller;
|
2
|
2
|
|
3
|
3
|
import com.pojo.entity.AEntity;
|
4
|
4
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
5
|
+import org.springframework.dao.EmptyResultDataAccessException;
|
5
|
6
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
6
|
7
|
import org.springframework.jdbc.core.JdbcTemplate;
|
7
|
8
|
import org.springframework.stereotype.Controller;
|
|
@@ -15,10 +16,14 @@ public class UserController {
|
15
|
16
|
@RequestMapping("uu")
|
16
|
17
|
@ResponseBody
|
17
|
18
|
public String uu() {
|
18
|
|
- AEntity aEntity = jdbcTemplate.queryForObject("select * from wb_tbl_a where id = ?",
|
19
|
|
- new BeanPropertyRowMapper<AEntity>(AEntity.class),
|
20
|
|
- "10"
|
21
|
|
- );
|
|
19
|
+ try {
|
|
20
|
+ AEntity aEntity = jdbcTemplate.queryForObject("select * from wb_tbl_a where id = ?",
|
|
21
|
+ new BeanPropertyRowMapper<AEntity>(AEntity.class),
|
|
22
|
+ "105"
|
|
23
|
+ );
|
|
24
|
+ } catch (EmptyResultDataAccessException e) {
|
|
25
|
+ return e.getMessage();
|
|
26
|
+ }
|
22
|
27
|
return "uu";
|
23
|
28
|
}
|
24
|
29
|
}
|