Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Locate images in html outside jar

In my application, i have to generate images on fly using java code and have to give a path of generated image in html page to show generated image to the user in html.

In my case,we can not place generated image in jar file on fly.So I can generate image file outside of the jar.But i can not locate image in html file.

Can you please help me out on this.

Jar file location is java -jar /usr/syam/test/test.jar

but i am generating images in /usr/syam/captcha/test.jpg

in html file,

Please help me on this.

like image 214
Shyam Elakapalli Avatar asked Feb 12 '23 01:02

Shyam Elakapalli


1 Answers

You can use resource handler e.g.

@Component
class WebConfigurer extends WebMvcConfigurerAdapter {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
         registry.addResourceHandler("/captcha/**").addResourceLocations("file:///usr/syam/captcha");
    }

}
like image 102
sodik Avatar answered Feb 13 '23 22:02

sodik