imageio.jar works as standalone but not as a web project

别等时光非礼了梦想. 提交于 2019-12-11 23:34:23

问题


I am having a spring mvc project with the basic pom.

I also have imageio.jar in build path.

    String format="tif";
System.out.println(format);
Iterator<ImageReader> readers = ImageIO
        .getImageReadersByFormatName(format);
System.out.println(readers.hasNext());

Iterator<ImageWriter> writers = ImageIO
        .getImageWritersByFormatName("tiff");
System.out.println(writers.hasNext());

When the above code is executes as a stand alone program i get the output as follows

tif
true
true

but when i add it to a Spring mvc controller mapping

@RequestMapping(value = "/test/{format}", method = RequestMethod.GET)
    public @ResponseBody
    String test(@PathVariable String format) {
        System.out.println(format);
        Iterator<ImageReader> readers = ImageIO
                .getImageReadersByFormatName(format);
        System.out.println(readers.hasNext());

        Iterator<ImageWriter> writers = ImageIO
                .getImageWritersByFormatName("tiff");
        System.out.println(writers.hasNext());

        return "Done";

    }

i get the output as

tif
false
false

Please help me in solving this issue.i really dono what is the problem.

I have a lot of work to be done based on this.

来源:https://stackoverflow.com/questions/22035048/imageio-jar-works-as-standalone-but-not-as-a-web-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!