String departmentName = request.getParameter("dept_name");
departmentName = new String(departmentName.getBytes(Charset.forName("UTF8")),"UTF8");
System.out.println(departmentName);//O/p: composés
在windows中,显示的输出是我所期望的,它也正在获取部门名称匹配条件的记录。
但在 Linux 中它返回“compos??s”,所以我的数据库查询失败。
谁能给我解决方案?
最佳答案
可能是因为字符集 UTF8
不存在。您必须使用 UTF-8
。查看javadoc .
关于java - Linux 中的 UTF-8 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15288317/