How to read post parameters using JS/Jquery

前端 未结 3 519
一向
一向 2021-01-21 05:39

I have integrated a payment gateway with a Java based Web-App Now, After a successful and failure transaction, PG accordingly redirect to respectively html pages failure.html,su

3条回答
  •  抹茶落季
    2021-01-21 06:25

    When Integrating with payment gateways or in general when you receive a
    redirection URL based on server response.Simply map your URL in controller or in Servlet.

    This way you can access the request parameters and based on parameter and other
    information you can redirect the page.

    Example: I've provided http://www.localhost.in/failure
    Map above url in your controller

      @RequestMapping(value = "/failure.do", method = RequestMethod.POST)
    public void pgResponse(@RequestBody ResonseBean bean, HttpServletRequest request, HttpServletResponse response )
    {
      try
      {
       // Here you can extract the parameters from POST request.
      String amount = (String) request.getParameter("amount");
      String addedon = (String) request.getParameter("addedon");
      String productinfo = (String) request.getParameter("productinfo");
      String firstname = (String) request.getParameter("firstname");
    
      // Do you business here
      //  Redirect when you're done
    
    
      }
      catch ( Exception e )
      {
    
      }
    

    }

    Or You can simply bind a Servlet in your not using Spring MVC, Spring Boot.

    In JSP Environment,
    Simply use scriptlet in jsp page.For Example:

    <%
    
     String amount = (String) request.getParameter("amount");
     String addedon = (String) request.getParameter("addedon");
     String productinfo = (String) request.getParameter("productinfo");
     String firstname = (String) request.getParameter("firstname");
    
    %>
    
    

    There are multiple way for this problem and it's subject to stack that you're using.

提交回复
热议问题