You do not need to create separate controllers for each call separately. You can handle multiple call addresses on a single class level. This becomes especially useful when the view for all requests is the same, but for example, filtered data is displayed depending on the address of the call.

In this example, we will make a car catalog skeleton in a typical MIRKA-trader-entrepreneur.

The configuration at the XML file level is the same as in the previous examples. All requests starting with / miro will be handled by Spring:

All magic is basically on the controller:

Notice that there is a new item here, namely “RequestMapping” at the class level. In addition to the individual methods, we have a separate “RequestMapping”. What is going on?

The point is that all calls that start with “/ germanplacaljak sold” (and in fact, it is basically “/ miro / germanplakaljak sold”) will be handled by this class. Now calling simply “/ miro / germanplacaljak”, the mapping will be assigned to the default, ie in the getAll method, the call “/ miro / germanplakaljak sold / bite” to the getBite method, and “” / miro / germanplakaljak sold / leftover “to getAction method.