Regarding the architecture of Spring, where is it correct to store images uploaded through a form? Images are photos of goods and, accordingly, they need to have access. How to specify the storage location?

If you specify so String path = this.getClass (). GetClassLoader (). GetResource (""). GetPath (); then the path will be in target, which means the folder will be deleted if you run maven clean.

Or you need to specify C: \ ... directly, but how then to be when transferring from a local server to a remote one.

    1 answer 1

    If we are talking about images uploaded through a form, then they need to be saved in a database .

    If these are pictures that need to be shown whenever the user opens some part of a page or a page, then create an img folder for all images, for example, WEB-INF / resources / img, and keep them there.

    • Thank you, but do you really need to store the files themselves in the database, and not a link to them (in terms of the name and the path to them)? And is it possible to dynamically get the path to "WEB-INF / resources / img"? - seltsam
    • If I understand correctly, then you can. For example, there will be entries in the database: [...] [imgId = '123d'] [...]; [...] [ingId = '114b'] [...]. You get the model and then assign the corresponding id of the image in src. But the important point is that these pictures should all be stored in resource / img, and all together and immediately. - JAVAvladuxa
    • but how to get get the path to "WEB-INF / resources / img"? - seltsam
    • <mvc: resources mapping = "resources / **" location = "/ WEB-INF / resources /" /> like this - JAVAvladuxa
    • Pictures will not be moved there while the program is running - I have already tried. - seltsam