How to determine if a parameter has been “posted” or “geted” from Java?

前端 未结 7 1736
离开以前
离开以前 2021-01-02 04:32

In ASP, there\'s request.form and request.queryString attributes, but in Java. It seems like we have only one collection, which can be accessed via

7条回答
  •  我在风中等你
    2021-01-02 05:01

    If you are writing a servlet, you can make that distinction by whether the doGet or doPost method is invoked.

    public void doGet(HttpServletRequest request,
                        HttpServletResponse response)
          throws ServletException{
    
     //Set a variable or invoke the GET specific logic
       handleRequest(request, response);
    
    }
    
    public void doPost(HttpServletRequest request,
                        HttpServletResponse response)
          throws ServletException{
    
     //Set a variable or invoke the POST specific logic
     handleRequest(request, response);
    
    }
    
    
    public void handleRequest(HttpServletRequest request,
                        HttpServletResponse response)
          throws ServletException{
    
     //Do stuff with the request
    
    }
    

提交回复
热议问题