October 2018
Intermediate to advanced
982 pages
23h 29m
English
The first rule of thumb when building web apps is to keep Spring controllers as light as possible. We can think of them as converters between HTTP traffic and our system.
To do that, we need to create a separate ImageService, as shown here, and let it do all the work:
@Service
public class ImageService {
private static String UPLOAD_ROOT = "upload-dir";
private final ResourceLoader resourceLoader;
public ImageService(ResourceLoader resourceLoader) {
this.resourceLoader = resourceLoader;
}
...
}
This last Spring service can be described as follows:
Read now
Unlock full access