S
S
Sland Show2018-10-16 19:53:22
Java
Sland Show, 2018-10-16 19:53:22

How to me to implement transfer of Map'y through session?

I have a controller. This controller has (relatively speaking) two methods: scheduleByStationsAndDatePersist and confirmBooking .

Now more about these methods. scheduleByStationsAndDatePersist forms a Map using its business logic. This Map has the following structure:

Map<ScheduleDTO, List<Schedule>> map = graphService.filter(list); // Map'ка инициализируется


Approximately this is stored in Map'ke:
Mars: [
  Schedule ( id: 71, 2018-10-18 12:00:002018-10-18 13:00:00, Toksovo →  Kavgolovo, train: Mars ), 
  Schedule ( id: 72, 2018-10-18 13:05:002018-10-18 14:00:00, Kavgolovo →  Oselki, train: Mars )
      ]

Aqua: [
  Schedule ( id: 73, 2018-10-18 12:10:502018-10-18 13:10:10, Toksovo →  Kavgolovo, train: Aqua ), 
  Schedule ( id: 74, 2018-10-18 13:25:002018-10-18 14:10:00, Kavgolovo →  Oselki, train: Aqua )
      ]


Where Marsand Aquais toString representation of the ScheduleDTO blank. The key here is this blank (I decided to display the name of the train just for clarity), and the value is a list of real Schedules from the database.

As a key, we have a ScheduleDTO blank to display in the front, and as a value, we have a list of compound Schedules . Then I form a regular list in scheduleByStationsAndDatePersist (I take the values ​​by key and glue all the schedules into one DTO) and send it to the JSP. So the second controller method is confirmBooking



must do the following: when the user has selected the schedule of interest to him and clicked on the link (there is a list of all collected schedules in the JSP), then I must do something so that I can pull out all the glued schedules from this very Map (which I purposely collected into one "blank"). And, let's say, if the user has chosen a blank with the first flight (where the train is Mars), then I'm specifically interested in this list of Schedules (which I can get by key).

And my question is: what is the best way to do this? Use session? Or is there an alternative?

Here is an example of this method:
@RequestMapping(value = "/viewTicketsTrainInfo")
    public String confirmBooking(Model model) {
...
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question