在 JSP 中:<%@page pageEncoding="UTF-8"%> <%@page language="java" contentType="text/html; charset=UTF-8"%>
在 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());
}
我得到了奇怪的字符。我在网上搜索了很多,找不到解决方案,请帮助。顺便说一句,我正在使用 Websphere7.0。