如何使用 javax.portlet.ActionResponse.sendRedirect 方法在 java 中发送 Post 请求?
How to Send Post request in java with javax.portlet.ActionResponse.sendRedirect method?
我想 POST 到 URL 但在将其设为 GET 之后,我怎样才能 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);
}
您是否尝试过使用 RequestDispater
而不是 response.sendRedirect?
保留原来的请求,没有改变。
因此,如果它是 POST,它将保持 POST。
我是通过使用 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
}
我想 POST 到 URL 但在将其设为 GET 之后,我怎样才能 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);
}
您是否尝试过使用 RequestDispater
而不是 response.sendRedirect?
保留原来的请求,没有改变。
因此,如果它是 POST,它将保持 POST。
我是通过使用 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
}