P
P
P_Alexander2019-10-14 16:32:00
Java
P_Alexander, 2019-10-14 16:32:00

How are many forms handled in one controller (Spring)?

Imagine a situation, there is a page and it has 5 forms and it is processed by one controller. How to handle 5 forms in this controller?
Of course, we can do this, but I have doubts about the literacy of this approach!?

@RequestMapping(value = "/main", method = RequestMethod.POST)
    public String process(@ModelAttribute("one") One one, @ModelAttribute("two") Two two, @ModelAttribute("three") Three three, @ModelAttribute("Four") Four four, @ModelAttribute("Five") Five five) {
 .... Тут обрабатываем.... а чти если пришла одна форма!? пользоваться if else ?!
}

To be more precise, my question is this: How can I process a large number of forms in one controller and have a separate method for processing the form, or somehow divide the load so that it does not bridge everything into one POST request?!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dinar Zaripov, 2019-10-15
@Donquih0te

I think this should help https://stackoverflow.com/a/7104977/8498513

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question