问题描述:

in an application based on Spring Web Flow and JSF, I need to make a post to another server passing some parameters. After post, navigation must continue on the other server.

I can make a post using Apache HttpPost, but then I don't know how to redirect result of post to browser and make it navigate on the other server.

Thanks in advance,

Teo

网友答案:

So if I understand correctly you are receiving a url as a result of the post request to the other server and you then need to redirect to that url from your webflow application. If I was in this situation I would define a view-state that simply printed a form and inject the url I received from the other server as the action and then put in a two-liner javascript that immediately submitted the form on page load. Something like this:

<form action="{renderedUrl}" method="post" id="redirectForm">
   <input type="hidden" name="someValueWeWantToPass" value="value" />
</form>


<script type="text/javascript">
   document.getElementById("redirectForm").submit();
</script>

This will immediately submit the form, with the in hidden post body values to the rendered url. Obviously this won't work if the user has javascript disabled but depending on your requirements that may be acceptable.

相关阅读:
Top