
We need an IDE and an application server to run the code that we will develop as we learn.
We need to create a project to add code. After development, we need to be able to deploy and test our code.
To build effective Spring MVC apps, we need business services that connect to the database. We'll use some built-in business services to help us get started.
We need to understand the methods and logic in the model artifact that we'll use for the Spring MVC project. We will also need to link it to the model's application context.
We need to be able to access the methods of the model from the controller layer, make calls, and return results.
We need to write a new Spring MVC controller to map to a required URL and redirect to a JSP path.
The chocolate store web application needs the functionality to have users register themselves. The model has methods to do this. We need to make this functionality available in the web application.
Currently, in the application, when the user enters their information and clicks on Save, they see a success message, but there is no way for them to check if the save operation did indeed work fine. You will create a profile view page that the user can access to view their profile, and a save command will be redirected to this profile page instead of a success message page.
You have implemented a user registration input form that lets users enter their data. But right now, you do not check if the input is valid data. What if the user enters an invalid e-mail or does not fill in some of the fields? To make sure that the user enters appropriate data, you will need to validate it after you receive it in the controller and before you save it to the database.
Now that you have let the user create new profiles by using the Register page, and also to view their profile on the View page, next, you'll be providing them with the edit functionality.
The Customer entity that you've used so far is what you'd call a "standalone" entity. You haven't really had to worry about relationships between entities so far. We'll now work with two entities that are related.
While we have made huge progress and have a web application on our hands that provides considerable functionality, it doesn't look very good. We will incorporate some styles, and better still, let users choose the styles or themes they want.
Currently, the chocolate store web application doesn't have a lot of options when it comes to languages. Everything is in English. If you'd like your application to be used by people across the globe, you'll need to provide support for multiple languages.
In our chocolate store application, there is no way for users to browse for products that are sold on the web store. You'll add a category list display on the home page, and on the category page, and you'll show the products that belong to that category.
You'll be creating a search form that lets users search for products based on a couple of search criteria.
We will define a couple of search restrictions and validate the user input.
The Spring chocolate store application has functionality to let users browse for products. However, if for some reason, a request fails, we should be able to provide a good experience to the user. A response in case of an error message should be a well-designed error page, with a brief description of the error and a way for the user to either retry or navigate back to the home page.
To enable purchases in the chocolate store application, you'll need to build the login functionality.
We currently do not have a way for a user of the chocolate store application to shop for products and place an order. In this tutorial, you will implement a shopping cart feature that lets the users do this.
You've implemented a shopping cart in the session in the previous tutorial. The user can add items to the cart, but there is no way to view the contents. In this tutorial, you'll implement a cart URL that displays the cart contents, and you will also implement a "Place order" button that lets them order the contents of the cart.
The chocolate store application has a shopping cart functionality that's closely tied to the logged-in user. However, there's no way to stop an unauthenticated user from adding items to the cart and placing an order. In this video, you will write a SecurityInterceptor that allows only a logged-in user to access any functionality related to the shopping cart.
In this video, you will publish a URL that shows a list of products in the store, with the view generated not by a JSP but by a Freemarker FTL file.
How can we add common elements to every page in our application? An easy way is to use a tiling framework such as Apache Tiles, which is what we will look at in this video.
Let's say we have a requirement to render product information on our website in various different formats. Right now, you can enter the URL products/product/productid to view the product information in HTML. However, let's say we need to make this information available to the user in XML and JSON formats. What would be the best way to implement a feature like this?
RESTful web services have gained in popularity over the years. It is widely considered by many to be an excellent alternative to the older SOAP web services specification. You'll implement a RESTful API for the Spring Chocolate store application.
In sections 2 and 3, we saw how to display the product catalog information to the user as HTML that they can read in their browsers. When publishing the same information as RESTful web services, there are a few different factors that you need to account for.
In the previous tutorial, you wrote the category REST controller that lets clients get category information. We'll now see how to implement product information as well as place an order using Spring MVC's REST support.
The REST APIs do not have error handling yet. If there is any error, we get the tc Server error page as the response. For REST APIs, it is important that we provide non-HTML payloads as the response for both success and error scenarios.
Building apps with Spring Boot is fast. But nothing can make things faster than having a website where you pick components off the menu and load a prebuilt app into your development environment.
When constructing an app, our architecture can impact many decisions down the road. For a solid, front-to-back app, we need several components.
Many platforms in the past have suffered stagnation when you download and install them. Spring Boot solves this by delivering its stack of open source components as a managed collection of versioned components that you can easily update.
When we upload images, there is always extra data that need to be associated with them. What is the easiest, simplest way to declare that data and associate it with an image?
Declare a repository with a Java interface and extend it with a custom finder, writing zero code.
We need to find, store, and delete images on disk and in the database. These operations must be made available as web operations.
How do you display, upload, and delete images?
Interacting with the RESTful image service using the command-line cURL
Create a web template to display a page of images.
Apps often need static assets to flesh out the UI layer.
How do you pick a file and upload it to a backend website
How do you delete an image?
How do you support paging as well as adjusting other backend settings?
When it's time to go to production, do you really have everything you need?
How do you figure out what Spring Boot automatically configured for you?
How do you tabulate custom measurements?
How to you check the health of custom things?
How do you include custom information with your app, including Git commit details?
How can you speed up the cycle of updating and changing backend code and frontend templates?
How do you code against unique cloud-based resources that are too hard to replicate locally?
How do you use breakpoints and other debugging tools against an app deployed remotely?
What if you want to release your app as a service to be launched when the system boots?
What if you wanted a command-line way to manage your application?
How do you create CRaSH commands to manage custom aspects of your app via ssh?
How do you enable a Spring Boot app to send and receive WebSocket messages?
How do you send WebSocket events from various parts of the app?
How do you subscribe for WebSocket messages in the frontend?
How do you respond to WebSocket events on a website?
How do I lock down a website?
How do you put in a comprehensive set of users to test-drive the site?
How do you move from an in-memory set of users to a real one based on a database?
How do I link an image with the currently logged-in user who uploaded it?
How do I restrict access based on the URL?
How do I write complex authorization rules such as "only the owner can delete an image"?
Have you often felt that when you create complex and robust applications the focus usually drifts from the functionality to the infrastructure?
This is where Spring MVC and Spring Boot come to the rescue. They are lightweight frameworks that will help you develop flexible and robust stand-alone applications without much hassle.
This Learning Path is designed to introduce you to advantages of having frameworks, such as Spring MVC and Spring Boot, while developing apps.
A Video Learning Path from Packt essentially contains multiple video courses that are logically tied together to provide you with a larger learning curve.
Let’s dig into what this Learning Path does. It gets you started with creating, deploying, and running a Spring MVC project using Spring Tool Suite and then moves onto building a Spring Boot application. It will also show you how to integrate model and business services based on an example of an online e-commerce chocolate store!
Once you have gained hands-on experience with Spring MVC, the course will introduce Spring Boot. Then move on to learn Spring Boot by scaffolding an application and understanding different aspects of it. In addition to that, you will also learn to secure applications against malicious behavior.
After completing the course, you will be able to successfully create stand-alone, Spring-based applications using Java that work on multiple platforms!
About the Authors:
For this Learning Path, Packt has brought the works of two authors who are working very closely with Java, Spring, and Spring Boot.
Koushik Kothagal has over 12 years of professional experience working with various server-side technologies and developing web applications. He has worked extensively with Java, Spring, Oracle, and other enterprise technologies. He loves teaching, and when he’s not coding Java, he’s probably teaching it! In his spare time, he runs the tutorial website Java Brains which covers various enterprise Java technologies.
Greg L. Turnquist has developed software professionally since 1997. From 2002 to 2010, he was part of the senior software team that worked on Harris' $3.5 billion FAA telco program, architecting mission-critical enterprise apps while managing a software team. He provided after-hours support to a nation-wide telco system and is no stranger to midnight failures and software triages. In 2010, he joined the SpringSource division of VMware, which was spun off into Pivotal in 2013.