How does the java web project upload user avatars and display them at the front desk?

for example, after the user uploads the profile photo, the image address is stored in the database. Is the address string here similar to WEB-INF/image/a.jpg?

Jun.09,2022

simple
directly transfer the files obtained through the form to the specified directory of the server and record the path to the database. When you need to display, use servers such as nginx to preview pictures directly or use mapping directories such as tomcat
complexity
use Ali's oss or Qiniuyun image services to store, push and record addresses. Then the stitching address displays


1. It is recommended that only the image name is stored in the image address, and the path can be specified when you use it, so as to facilitate the migration of image resources.
2. The access path for uploaded images is generally any folder under / resources/static , such as / resources/static/images . When accessing images, you can access them through the https://xxx.com/images/xxx.png path.

Menu