In JSP: <%@page pageEncoding="UTF-8"%> <%@page language="java" contentType="text/html; charset=UTF-8"%>
In Servlet: request.setCharacterEncoding("UTF-8");
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List items = upload.parseRequest(aaReq);
Iterator iterator = items.iterator();
while (iterator.hasNext())
{
FileItem item = (FileItem) iterator.next();
System.out.println(item .getString("UTF-8").trim());
}
I am getting weird charactors. I have searched all over the web, not able to find the solution, please help. BTW i am using Websphere7.0.
The code above works for Chinese. I made some silly error elsewhere.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.