Manually creating a Spring MVC controller for a JPA entity
If you want to create a custom controller, then Roo offers a controller
class
command that creates the skeleton structure of a controller and a JSPX view to let you quickly get started.
Let's consider that in our flight-app
application we have the following entities:
Customer
: Represents a customer in the flight booking applicationAddress
: Represents the address of the customer
For the sake of simplicity, let's assume that there is a one-to-one bidirectional relationship between Customer
and Address
entities, the Customer
being the owner of the relationship. The Customer
entity has only one field: the customerName
and the Address
entity has two fields: addressLine1
and addressLine2
.
Let's say the flight-app
application requires that the Customer
and the corresponding Address
entities are created from the same form. When the user enters the customer's name and clicks the Add address button (as shown in the next screenshot), then the...