[英]How to correctly read accented characters in Java with Servlets and MySQL?
我的問題是,我無法在數據庫中插入帶重音符號的字符(áéíúññ)。
這是我的輸出控制台 :
如您所見, grupo
列的原始文本是Cómputo integrál
。
在我的輸出Web瀏覽器中也會發生相同的情況:
這是我的servlet代碼:
//Save the input form and search immediately
tx.begin();
Salon get = (Salon) session.get(salon.getClass(), 1);
tx.commit();
request.setCharacterEncoding("utf8");//Línea para que se ingresen de forma correcta los caracteres.
response.setContentType("text/html;charset=ISO-8859-1");
try (PrintWriter out = response.getWriter())
{
out.println("Salida de texto: " + get.getGrupo());
}
這是我的meta html代碼:
<meta charset="UTF-8">
並且我的數據庫配置有排序規則utf8 - utf8_spanish_ci
如何正確保存,插入,顯示和更新?
嘗試在與數據庫的連接的URL中添加以下內容:
jdbc:mysql:// localhost / mydb? useUnicode =是 & characterEncoding = UTF-8
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.