Hi everyone, I am learning spring boot using Java not Kotlin (for now). I am stuck in serving static images. Currently, my app is serving one image with this code:
The thing is, I have 7 images, and I believe there has to be a better way than writing this method 7 times. Can someone point me in the right direction? I want generic method for serving images.
g
GarouDan
12/12/2019, 4:15 PM
You can pass parameters to your controller function (which will be in your json payload at the request). With that you could pass the image name or an id for example
m
minucha
12/12/2019, 4:19 PM
You mean like these :
@RequestMapping("/{imageName}"
etc etc and I search for a file, and then if it finds it, then it will return the image, if not I throw exception.
Thanks pal, trying it now 🙂