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

2019-08-18 02:49发布

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.

0条回答
登录 后发表回答