[code]SmartUpload upLoad = new SmartUpload(); //SmartUpload组件
try
{
upLoad.initialize(getServlet().getServletConfig(),request,response);
upLoad.upload(); or upLoad.upload(“。。。”);
}
catch (Exception e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
Request upLoadRequest = upLoad.getRequest();
String ext = upLoad.getFiles().getFile(0).getFileExt() ; //得到后缀
String s = 地址+文件名;
upLoad.getFiles().getFile(0).saveAs(s) ; [/code]
乱码问题:
String value = new String(m_binArray, m_startData, (m_endData - m_startData) + 1);
这是smartupload 处理其他数据的时候使用的方法。
string 如果没有encode 的情况下使用的是系统默认的。
可能需要你重新编译这部分
String value = new String(m_binArray, m_startData, (m_endData - m_startData) + 1[color=red],"UTF-8"[/color]);
try
{
upLoad.initialize(getServlet().getServletConfig(),request,response);
upLoad.upload(); or upLoad.upload(“。。。”);
}
catch (Exception e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
Request upLoadRequest = upLoad.getRequest();
String ext = upLoad.getFiles().getFile(0).getFileExt() ; //得到后缀
String s = 地址+文件名;
upLoad.getFiles().getFile(0).saveAs(s) ; [/code]
乱码问题:
String value = new String(m_binArray, m_startData, (m_endData - m_startData) + 1);
这是smartupload 处理其他数据的时候使用的方法。
string 如果没有encode 的情况下使用的是系统默认的。
可能需要你重新编译这部分
String value = new String(m_binArray, m_startData, (m_endData - m_startData) + 1[color=red],"UTF-8"[/color]);
本文介绍了一种使用SmartUpload组件上传文件过程中遇到的乱码问题及其解决方案。通过调整String对象的构造方法,指定字符集为UTF-8,解决了由系统默认字符集导致的乱码问题。

1358

被折叠的 条评论
为什么被折叠?



