如何使用javax.portlet.ActionResponse.sendRedirect方法在java中发送Post请求?

时间:2017-04-06 11:13:19

标签: servlets portlet

我想发布到URL,但是在将其作为GET之后,那么如何发布

Sub SaveCSV()
rundate = DateTime.Now
runname = Application.UserName
savename = rundate & runname
sfilename = ActiveWorkbook.Path & "\" & savename & ".csv"

   ActiveWorkbook.Save

    ActiveWorkbook.SaveAs Filename:=sfilename, FileFormat:=xlCSV
Application.DisplayAlerts = True
End Sub

2 个答案:

答案 0 :(得分:0)

您是否尝试使用RequestDispater而不是response.sendRedirect?

它会保留原始请求,而不会更改它。

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

答案 1 :(得分: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
}
相关问题