smartupload上传文件编码问题 20
<%@pagelanguage="java"import="java.util.*"pageEncoding="UTF-8"%><%Stringpath=request....
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'smart02.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%response.setCharacterEncoding("UTF-8"); %>
<form action="smartupload01.jsp" method="post" enctype="multipart/form-data">
请上传你的文件:<input type="file" name="pic" >
文件命名为:<input type="text" name="uname">
<input type="submit" name="submit" value="提交">
</body>
</html>
这个是接受的文件
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<jsp:useBean id="smartupload" class="com.jspsmart.upload.SmartUpload"/>
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'smartupload01.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
hello
<%
request.setCharacterEncoding("UTF-8");
smartupload.initialize(pageContext);
smartupload.upload();
smartupload.save("upload");
String name=smartupload.getRequest().getParameter("uname");
String name2=name;
name=name+"."+smartupload.getFiles().getFile(0).getFileExt();
String fileName=this.getServletContext().getRealPath("/")+"upload"+name;
smartupload.getFiles().getFile(0).saveAs(fileName);
%>
<h1><%=name%></h1>
原来的文件名称是 <h1><%=name2%></h1>
</body>
</html>
明明两边都声明了我上传的文件是采用UTF-8编码,而且我页面的默认编码也是UTF-8,为什么服务器显示的时候还是出现乱码,无论我吧response.setEncoding删除还是不删除,还是说把request.setEncoding 删除,还是把request.setEncoding改成GBK都是出现乱码的,求高手指教啊 展开
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'smart02.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%response.setCharacterEncoding("UTF-8"); %>
<form action="smartupload01.jsp" method="post" enctype="multipart/form-data">
请上传你的文件:<input type="file" name="pic" >
文件命名为:<input type="text" name="uname">
<input type="submit" name="submit" value="提交">
</body>
</html>
这个是接受的文件
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<jsp:useBean id="smartupload" class="com.jspsmart.upload.SmartUpload"/>
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'smartupload01.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
hello
<%
request.setCharacterEncoding("UTF-8");
smartupload.initialize(pageContext);
smartupload.upload();
smartupload.save("upload");
String name=smartupload.getRequest().getParameter("uname");
String name2=name;
name=name+"."+smartupload.getFiles().getFile(0).getFileExt();
String fileName=this.getServletContext().getRealPath("/")+"upload"+name;
smartupload.getFiles().getFile(0).saveAs(fileName);
%>
<h1><%=name%></h1>
原来的文件名称是 <h1><%=name2%></h1>
</body>
</html>
明明两边都声明了我上传的文件是采用UTF-8编码,而且我页面的默认编码也是UTF-8,为什么服务器显示的时候还是出现乱码,无论我吧response.setEncoding删除还是不删除,还是说把request.setEncoding 删除,还是把request.setEncoding改成GBK都是出现乱码的,求高手指教啊 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询