I switch to Java EE with PHP, in all frameworks for PHP one controller can handle different URIs. For example, for URLs like http://somesite.ru/controller/action, the framework will transfer control to the Action method of the Controller class. In Java EE, the controllers are Servlets, but it has only doGet and doPost, that is, they conveniently handle only one URI. Doesn't Java know how to map multiple URIs to different Servlet methods? And for every sneeze, for example, in fact, belonging to one controller URI user / login, user / logout, etc. do I produce a bunch of servlets?

  • It depends on how you look at first. And secondly, the servlet no controller, and the lowest level of request processing. If you need controllers, use frameworks like JSF or Spring . ReSTful has its own JAX-RS add JAX-RS . - Sergey
  • Although JSF is a solution out of the box, it can be too different from past experience, and not everyone knows how to cook it. I do not know how things are in Spring , but it seems you will like it more. Look, if its principles seem familiar, then at JSF you can not even lose time. Perhaps thanks to him (spring-y), these controllers spread everywhere. - Sergey
  • @Sergey thanks for the answer, in some articles the servlets have been positioned exactly as controllers, so this analogy has crept into me. So it will be necessary to make some kind of class similar to the query router. I will dig in the direction of Spring. - Sergey Bolotaev

0