使用Mybatis带参查询时,如果没有构建实体类,select中的resultType为hashmap,在controller类里面拿到值之后,如果传进去的值为中文,必须进行转码
本人的controller类
public Map<String, Object> QueryClass(@RequestParam(“username”) String username) {
Map<String, Object> map = new HashMap();
private QueryClassService QcBiz;
try {
username = new String(username.getBytes(“ISO-8859-1”), “UTF-8”);
List list = this.QcBiz.QueryClass(username);
map.put(“respCode”, “000”);
map.put(“respMsg”, “成功”);
map.put(“data”, list);
} catch (Exception var) {
map.put(“respCode”, “001”);
map.put(“respMsg”, “失败”);
}
return map;
}
}
SSM中mybatis模糊查询数据库有值,控制台为空
最新推荐文章于 2023-02-14 07:03:53 发布