我的java是这样写的
import java.io.*;
import java.awt.Image;
import java.awt.image.*;
import com.sun.image.codec.jpeg.*;
import java.sql.*;
import java.util.*;
import org.apache.commons.fileupload.*;
import org.apache.commons.fileupload.disk.*;
import com.jspsmart.upload.*;
import javax.servlet.jsp.PageContext;
public class UploadPic{
public boolean upload(PageContext pageContext) {
SmartUpload mySmartUpload = new SmartUpload();
long file_size_max = 4000000;
String fileName2 = "", ext = "", testvar = "";
try {
mySmartUpload.initialize(pageContext);
mySmartUpload.setAllowedFilesList("jpg,gif");
mySmartUpload.upload();
}
catch (Exception e){
System.out.println("只允许上传.jpg和.gif类型图片文件");
}
//com.jspsmart.upload.File
com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(0);
if (myFile.isMissing()) {
System.out.println("没有文件");
return false;
}
//String myFileName=myFile.getFileName(); //取得上载的文件的文件名
ext = myFile.getFileExt(); //取得后缀名
int file_size = myFile.getSize(); //取得文件的大小
String saveurl = "";
if (file_size < file_size_max) {
//更改文件名,取得当前上传时间的毫秒数值
try{
myFile.saveAs("/upload/sample.tmp", mySmartUpload.SAVE_PHYSICAL);
}catch(Exception e1){
System.out.println("不能保存");
}
}
else {
System.out.println("上传文件大小不能超过" + (file_size_max / 1000) + "K");
}
return true;
}
}
编译能通过 tomcat 也不报错,但在页面显示
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: com/jspsmart/upload/SmartUpload (Unsupported major.minor version 49.0)
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.inventory.receive_jsp._jspService(receive_jsp.java:135)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.pfc.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:122)
root cause
java.lang.UnsupportedClassVersionError: com/jspsmart/upload/SmartUpload (Unsupported major.minor version 49.0)
java.lang.ClassLoader.defineClass0(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:537)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1634)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:860)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1307)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
com.pfc.inventory.UploadPic.upload(UploadPic.java:20)
org.apache.jsp.inventory.receive_jsp._jspService(receive_jsp.java:120)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.pfc.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:122)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
求各位给看看