中文编码不对试试转化一下public static String toGBK(String str) {
String temp = str;
try {
if (temp == null) {
temp = "";
}
if (temp.equals("null")) {
temp = "";
}
byte[] b = temp.getBytes("ISO8859-1");
str = new String(b, "GBK");
} catch (UnsupportedEncodingException uee) {
}
return str;
}
String temp = str;
try {
if (temp == null) {
temp = "";
}
if (temp.equals("null")) {
temp = "";
}
byte[] b = temp.getBytes("ISO8859-1");
str = new String(b, "GBK");
} catch (UnsupportedEncodingException uee) {
}
return str;
}
解决方案 »
- jfreechart折线图中如何实现点到点的线带箭头
- 请问:一般的网上支付是如何实现的?
- 一个小问题,如果把JSP的参数传递给servlet
- 谁知道CSDN论坛左边消息框里的右键菜单是怎么实现的?
- java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] 参数不足,期待是 1。
- 关于JSP传参问题
- 在线求助JSP运行出错的问题!!顶者撒分
- 如何在页面隐藏Tomcat服务器的信息?
- decimalbox输入框限制大小问题
- (●●●●,高分200)在哪里能下载到windows2000下连接mysql的jdbc驱动,又如何配置呢?(急、再线等待)
- 好家伙。挖地三尺。终于把你找到了———mod_jk.dll。与csdn兄弟分享。
- session 的时效
<%@ page import="org.apache.commons.fileupload.*,java.util.*,java.io.*"%>
<%
String updir = "/uploadimg/";
String filePath = getServletContext().getRealPath(updir) ;
String picurl = "";
Utils.Mkdir(filePath); //创建目录
DiskFileUpload fu = new DiskFileUpload();
fu.setHeaderEncoding("GBK");
fu.setSizeMax(1000000000);//图片大小限制为1000M
fu.setSizeThreshold(4096);
fu.setRepositoryPath("/tmp");
List fileItems = fu.parseRequest(request);
Iterator iter = fileItems.iterator();
while(iter.hasNext()){
FileItem item = (FileItem)iter.next();
if( !item.isFormField() ){
String name = item.getName();
name = name.replace('\\','/');
File fullFile = new File(name);
File savedFile = new File(filePath,fullFile.getName());
item.write(savedFile);
picurl += "/" + fullFile.getName();
}
}
%>picurl的值对了,但是文件上载后保存的文件名总是乱码,不知如何解决。