上代码
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String type = request.getParameter("type");// 判断操作类型:上架、修改、或者查看物品信息
// 类型是上架物品
if (type.equals("add")) {
SmartUpload smart = new SmartUpload();// 创建一个smart对象
smart.initialize(getServletConfig(), request, response);// 初始化smart
try {
// 准备上传
smart.upload();
} catch (SmartUploadException e) {
// TODO Auto-generated catch block
System.out.println("smart上传bug");
}
File picFile=smart.getFiles().getFile(0);//获得第一个文件
String picName=new String(picFile.getFileName().getBytes("gbk"),"UTF-8");
//String picName=picFile.getFileName();
System.out.println("文件名:"+picName);//这里得到的结果 :文件名:小叶吱吱??jpeg 文件原名:小叶吱吱吱.jpeg