jfinal編碼問題及解決

使用jfinal出現了常見的編碼問題狀況html

public void test() {
Random r = new Random();

try {
Connection conn = createConnection();
Statement st = conn.createStatement();
String sql = "insert into encode_test values(" + r.nextInt() + ", '漢字')";
System.out.println("SQL: " + sql);
st.execute(sql);
st.close();
conn.close();

conn = DbKit.getConfig().getConnection();
st = conn.createStatement();
sql = "insert into encode_test values(" + r.nextInt() + ", '漢字測試c3p0')";
System.out.println("SQL: " + sql);
st.execute(sql);
st.close();
conn.close();


sql = "insert into encode_test values(" + r.nextInt() + ", '漢字')";
Db.update(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
renderText("OK");
}

用以上原始的代碼是正確的,可是使用druidplugin時出現了問題mysql

public void login(){
        User user=getModel(User.class);
        user.save();
        render("/result.html");
        System.out.println("ok!");

這裏寫圖片描述

解決辦法sql

prop加上markdown

jdbcUrl = jdbc:mysql://localhost:3306/wsy_student?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull

便可解決問題dom

這裏寫圖片描述

相關文章
相關標籤/搜索