fileupload上传表单中的文本字段都是乱码? 页面是utf-8,上传时候出现乱码,怎么才能解决呢?用filter当然最好,有例子吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 操,分给的低就每人回答,还得靠自己,什么世道,连jb这点虚拟货币也计较,sb // --------------------------------------------------------------------------------------------------------- //加载表单 private void loadRequestData(HttpServletRequest request) { boolean isMultipart = false; try { isMultipart = FileUpload.isMultipartContent(request); if (isMultipart) { DiskFileUpload upload = new DiskFileUpload(); upload.setHeaderEncoding("UTF-8"); requestDataItems = upload.parseRequest(request); } } catch(Exception e) { requestDataItems = null; } }// --------------------------------------------------------------------------------------------------------- //获取表单对象 private FileItem getFormValue(String fieldName) throws FileUploadException, UnsupportedEncodingException { try { if (requestDataItems != null) { Iterator iter = requestDataItems.iterator(); while (iter.hasNext()) { FileItem item = (FileItem)iter.next(); if(item.getFieldName().equals(fieldName)) { return(item); } } } } catch(Exception e) { outExceptionInfo(e); } return(null); }// --------------------------------------------------------------------------------------------------------- //获取表单中的值(过滤器) private String getRequestValue(String fieldName) throws UnsupportedEncodingException { String strResult = ""; FileItem item = null; try { item = getFormValue(fieldName); strResult = item.getString("iso8859-1"); byte b[] = strResult.getBytes("iso8859-1"); strResult = new String(b, "UTF-8"); } catch(Exception e) {} return(strResult); } 求教在线等,jsp访问数据库 急急急,求救高手,SOS 关于对日开发前景? 文件上传与查看 请问怎样用JSP调用MYSQL存储过程并返回结果集 tomcat 启动时自动加载servlet配置 Myface JscookMenu问题 救命,JSP编译后出现的问题,请大侠指点,倾囊相赠 郁闷中!想学servlet,却不会配置!!请高手们帮帮忙吧!我真的想学Java! 字符%为什么不能用request传送? 求jsp上传文件的详细范例,谢谢! oracle sql语句问题帮帮忙
//加载表单
private void loadRequestData(HttpServletRequest request)
{
boolean isMultipart = false;
try
{
isMultipart = FileUpload.isMultipartContent(request);
if (isMultipart)
{
DiskFileUpload upload = new DiskFileUpload();
upload.setHeaderEncoding("UTF-8");
requestDataItems = upload.parseRequest(request);
}
}
catch(Exception e)
{
requestDataItems = null;
}
}
// ---------------------------------------------------------------------------------------------------------
//获取表单对象
private FileItem getFormValue(String fieldName) throws FileUploadException, UnsupportedEncodingException
{
try
{
if (requestDataItems != null)
{
Iterator iter = requestDataItems.iterator();
while (iter.hasNext())
{
FileItem item = (FileItem)iter.next();
if(item.getFieldName().equals(fieldName))
{
return(item);
}
}
}
}
catch(Exception e)
{
outExceptionInfo(e);
}
return(null);
}
// ---------------------------------------------------------------------------------------------------------
//获取表单中的值(过滤器)
private String getRequestValue(String fieldName) throws UnsupportedEncodingException
{
String strResult = "";
FileItem item = null;
try
{
item = getFormValue(fieldName);
strResult = item.getString("iso8859-1");
byte b[] = strResult.getBytes("iso8859-1");
strResult = new String(b, "UTF-8");
}
catch(Exception e)
{}
return(strResult);
}