Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javax.imageio.IIOException:无法读取Servlet中的输入文件_Java_Servlets - Fatal编程技术网

javax.imageio.IIOException:无法读取Servlet中的输入文件

javax.imageio.IIOException:无法读取Servlet中的输入文件,java,servlets,Java,Servlets,我正在比较两张我存储在项目内pic文件夹中的图像 在编译期间,我遇到了IOException 我尝试了以前所有的解决方案,但仍然不起作用 请帮我修正这个错误 在这个项目中,我使用servlet页面 这是我的Servlet方法 您应该尝试获取如下所示的文件 File fileA = new File(getServletContext().getRealPath("pic/image2.jpg")); File fileB = new File(getServletContext().getRea

我正在比较两张我存储在项目内pic文件夹中的图像

在编译期间,我遇到了IOException 我尝试了以前所有的解决方案,但仍然不起作用 请帮我修正这个错误 在这个项目中,我使用servlet页面

这是我的Servlet方法
您应该尝试获取如下所示的文件

File fileA = new File(getServletContext().getRealPath("pic/image2.jpg"));
File fileB = new File(getServletContext().getRealPath("pic/image2.jpg"));

您的pic文件夹位于什么位置?在项目目录的WebContent中fileA=new FilegetServletContext.getRealPathpic/image2.jpg;
javax.imageio.IIOException: Can't read input file!
Dec 12, 2017 12:26:30 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [services.CompareImage] in context with path [/JavaCvServlet] threw exception
File fileA = new File(getServletContext().getRealPath("pic/image2.jpg"));
File fileB = new File(getServletContext().getRealPath("pic/image2.jpg"));