The problem of doGet method and doPost method in Java servlet

are these two methods called whenever an post request or a get request is encountered?
then, if there are multiple requests in a web page, isn"t it troublesome to call these two methods
to solve


get request call doGet,post request call doPost.
then I don't quite understand what you mean it's troublesome. Multiple requests in a web page do not necessarily call methods in the same Servlet.


at first, there is only the processRequest method, and all requests, whether get or post, are handled here, and then it is simply encapsulated to distinguish between doget and dopost APIs. You can also do further encapsulation similar to spring mvc, which is also post requests. Different methods are used to deal with them according to different url.

Menu