日期:2014-05-17 浏览次数:20927 次
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!--<jsp:useBean id="smartupload" class="com.jspsmart.upload.SmartUpload"/>--> <%@page import="com.jspsmart.upload.SmartUpload"%> <%@page import="java.util.*,java.io.*,java.sql.*"%> <%@ page import="com.ucap.system.db.*"%> <% //request.setCharacterEncoding("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 'smartupload04.jsp' starting page</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <% // request.setCharacterEncoding("utf-8") ; //response.setContentType( smartupload.initialize(pageContext) ; // 初始化上传 smartupload.upload() ; // 准备上传 String name = smartupload.getRequest().getParameter("uname") ; System.out.println(smartupload.getRequest().getParameter("pic")); //name=new String(name.getBytes("gbk"),"utf-8"); //ISO-8859-1 //request.getParameter("uname"); // System.out.println("name:"+name); name = name + "." + smartupload.getFiles().getFile(0).getFileExt() ; System.out.println(name); System.out.println("getServletContext:"+this.getServletContext()); String fileName = this.getServletContext().getRealPath("/") + "upload/" + name ; System.out.println("fileName:"+fileName); smartupload.getFiles().getFile(0).saveAs(fileName) ; name = java.net.URLDecoder.decode(name,"utf-8"); %> <img src="upload/<%=name%>" width="300" height="200" /><%=name %> </body> </html>
contentType="text/html; charset=UTF-8"
------解决方案--------------------
瞅瞅,.....
一般我都用的是GBK