如何从外部站点获取POST数据

时间:2013-11-13 12:12:13

标签: jsf http-post managed-bean http-request-parameters

外部站点将用户重定向到我的平台,传递一些POST数据。如何从我的Bean中获取此信息并将其显示在JSF页面中?

我尝试了很多解决方案,但没有人工作。以下是JSF测试页面。

 <f:metadata>
  <f:viewParam name="auth" value="#{getResponse2.auth}" required="true"/>
 </f:metadata>

<ui:define name="content">
    <center>
       An error occurred during  transaction
        #{getResponse2.auth}<br />
        #{getResponse2.responsecode}
    </center>

这里有一些尝试获取POST数据:

@ManagedBean
@RequestScoped
public class getResponse extends HttpServlet {
   private String paymentId;
   private String result;
   private String auth;
   private String ref;
   private String traind;
   private String trackid;
   private String udf1;
   private String responsecode;
   private String host;
   @Override
   public void doPost(HttpServletRequest request, HttpServletResponse response) {
      paymentId = request.getParameter("paymentid");
      result = request.getParameter("result");
      auth = request.getParameter("auth");
      ref = request.getParameter("ref");
      traind = request.getParameter("tranid");
      trackid = request.getParameter("trackid");
      udf1 = request.getParameter("udf1");
      responsecode = request.getParameter("responsecode");
      System.out.println("response code: " + responsecode);
  }

另一个:

   public void getResponse() {

    paymentId = ((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()).getParameter("paymentId");
    result = ((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()).getParameter("result");
    auth = ((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()).getParameter("auth");
    ref = ((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()).getParameter("ref");
    traind = ((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()).getParameter("traind");
    trackid = ((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()).getParameter("trakid");
    udf1 = ((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()).getParameter("udf1");
    responsecode = ((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()).getParameter("responsecode");

}

0 个答案:

没有答案