I have following folder structure:
ProjectFolder/images/some images
In the same folder
ProjectFolder/WEB-INF/classes/com/xyz/here is java file of controller.
How can I get the image path in the controller?
Please, help. Thanks :)
If its a web context may be something like this could help
InputStream is = null ;
is = request.getSession().getServletContext().getResourceAsStream("/images/someimage.jpg");
or may be something like this:
InputStream is = null ;
String realPath = request.getSession().getServletContext().getRealPath("/images/someimage.jpg");
is = new FileInputStream(realPath);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With