Exception in thread "main" java.lang.ExceptionInInitializerError
at com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi.createReaderInstance(JPEGImageReaderSpi.java:67)
at javax.imageio.spi.ImageReaderSpi.createReaderInstance(ImageReaderSpi.java:296)
at javax.imageio.ImageIO$ImageReaderIterator.next(ImageIO.java:503)
at javax.imageio.ImageIO$ImageReaderIterator.next(ImageIO.java:487)
at javax.imageio.ImageIO.read(ImageIO.java:1417)
at javax.imageio.ImageIO.read(ImageIO.java:1282)
at com.eeline.util.TestZipImage.InputImage(TestZipImage.java:41)
at com.eeline.util.TestZipImage.Tosmallerpic(TestZipImage.java:196)
at com.eeline.util.TestZipImage.Tosmallerpic(TestZipImage.java:97)
at com.eeline.util.TestZipImage.main(TestZipImage.java:280)
Caused by: java.lang.IllegalArgumentException: Can't load standard profile: GRAY.pf
at java.awt.color.ICC_Profile$2.run(ICC_Profile.java:894)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.color.ICC_Profile.getStandardProfile(ICC_Profile.java:887)
at java.awt.color.ICC_Profile.getInstance(ICC_Profile.java:858)
at java.awt.color.ColorSpace.getInstance(ColorSpace.java:315)
at javax.imageio.ImageTypeSpecifier$Grayscale.<init>(ImageTypeSpecifier.java:587)
at javax.imageio.ImageTypeSpecifier.createGrayscale(ImageTypeSpecifier.java:668)
at javax.imageio.ImageTypeSpecifier.createSpecifier(ImageTypeSpecifier.java:1184)
at javax.imageio.ImageTypeSpecifier.getSpecifier(ImageTypeSpecifier.java:1101)
at javax.imageio.ImageTypeSpecifier.createFromBufferedImageType(ImageTypeSpecifier.java:884)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.<clinit>(JPEGImageReader.java:208)
... 10 more
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.jspsmart.upload.File;
import com.jspsmart.upload.Files;
import com.jspsmart.upload.SmartUpload;
import com.jspsmart.upload.SmartUploadException;
public class FileUpload extends HttpServlet {
//定义一个ServletConfig对象
private ServletConfig sc;
/**
* Constructor of the object.
*/
public FileUpload() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.flush();
out.close();
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
response.setContentType("text/html;charset=utf8");
PrintWriter out = response.getWriter();
//新建一个SmartUpload对象,接收用户上传文件
SmartUpload su = new SmartUpload();
su.initialize(sc, request, response);
su.upload();
Files fs = su.getFiles();
File frist = fs.getFile(0);
String filename = frist.getFileName();
String sctm = System.currentTimeMillis()+"";
//获得文件的扩展名
String ext = frist.getFileExt();
//把文件保存到服务器硬盘(以系统毫秒数命名)
frist.saveAs("/"+sctm+"."+ext);
String username = su.getRequest().getParameter("username");
System.out.println(username);
out.flush();
out.close();
} catch (SmartUploadException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void init(ServletConfig sc) throws ServletException {
// Put your code here
this.sc = sc;
}
}
jsp代码:
<body>
<form action="fileUpload" method="post" enctype="multipart/form-data">
<input type="file" name="fileXXX" /><!-- 不懈这个name就接收不到,使用不到 -->
用户名:<input type="text" name="username" />
<br/>
<input type="submit" />
</form>
</body>追问
谢谢!!这个是上传图片吧? 我这个是压缩图片所报的错