1,尝试引入Iso2Utf
package com.dafu.util; public class Iso2Utf { public static String encode(String searchText){ if (null != searchText&&!searchText.equals("")) { try { searchText = new String(searchText.getBytes("ISO-8859-1"), "UTF-8"); } catch (Exception e) { e.printStackTrace(); } }else{ searchText=""; } return searchText; } }
String str=Iso2Utf.encode(str);
2,在jdbc,url数据库后边加修改编码格式
?useUnicode=true&characterEncoding=UTF-8
jdbc.url=jdbc:mysql://localhost:3306/HelloWorld?useUnicode=true&characterEncoding=UTF-8