2
I’m learning to use the Spring Boot
and I need to create a field in the form that loads the image to be used. How do I map the directory and save to a particular project folder?
Example: through the form, the user will upload the photo. Instead of saving the image in the database, how do I save only the directory that will load the image in the view
? Adding, and if possible, how to load this image by the control class?
Please, Before you go negative on my question, I’ve seen some answers, so far on stackoverflow
, but I’m still having doubts about how to proceed within the domain classes. Example of domain class:
Observing: am using MySQL
.
package com.ptestes.models;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class HotSite implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
private String pageTitle;
@?????
private <?????> img;
/*Getters and Setters*/
}
From now on, thank you very much! ^_^
I believe that that can help you.
– StatelessDev
The article is cool, but it teaches you to save directly in the BD. I would like to save the directory and upload the image using the
controller
.– Van Ribeiro