2017-04-06 111 views
0

我要张贴到URL,但以下使得它作为GET,所以我怎么可以张贴如何使用javax.portlet.ActionResponse.sendRedirect方法发送java中的Post请求?

Object portletResponse = webAppAccess.getHttpServletRequest() 
      .getAttribute(Constants.PORTLET_RESPONSE); 

    if (portletResponse instanceof javax.portlet.ActionResponse) { 
      javax.portlet.ActionResponse actionResponse = (javax.portlet.ActionResponse) portletResponse; 

      actionResponse.sendRedirect(URL); 
     } 
+0

重定向总是GET,根据定义。 –

回答

0

我已经通过使用FORM POST方法做到了这一点,如下所示。

webAppAccess.processPage("importedPage"); 

加在模型此导入页:

<HTML> 
<HEAD> 
<title>New Page</title> 
</HEAD> 
<Body onload=""> 
<form id="FormID" method="POST" action="actionURL"> 
    <input type="hidden" name="id" id="ID" value="<%=webAppAccess.getVariables().getString("ID")%>"/> 
    <noscript> 
     <p>Your browser does not support JavaScript or it is disabled. 
      Please click the button below to process the request. 
    </p> 
     <input type="submit" value="Proceed " name ="submit"></input> 
    </noscript> 
    <script> 
    document.getElementById('FormID').submit(); 
    </script> 
</form> 

和如下然后MVC控制器映射:

@RequestMapping(value = {"/Details"}, method = RequestMethod.POST) 
public String mthDetails(final Model p_model, @RequestParam(value = "id", required = false) final String p_ID){ 

    //code for further logic using ID 
} 
0

您是否尝试过使用RequestDispater代替response.sendRedirect是?

它保留原来的请求,而不改变它。

因此,如果它是POST,它将保持POST状态。

+0

可以显示如何使用它。 –

+0

,我想从WAS发送到tomcat –