2

I am building a web application using Spring framework that requires users to make a payment. When the user posts a form, it redirects to Hp's payment website and processes the payments there before returning to my application. This method however leaves my applications vulnerable to security threats and form manipulations.

I now want to post the form to my server, validate users inputs and if necessary post data to hp's web server. I have already written a java code for posting a form from my code and getting the response back into a file from hp's site but am unable to figure out how to redirect the user to the hp website using the java form post. Can someone please help? I am new to Spring so am open to suggestions that would help me accomplish this task either using this method or another way to do so.

Thanks

4

1 回答 1

2

显然,您需要在服务器端执行重定向,而不是在客户端。重定向基本上是返回 HTTP 302,Location标头指向新位置。当浏览器收到这样的响应时,它会打开相关的 URL,而不是像 200 那样呈现响应。

如果您可以接收并验证您​​的表单,您所要做的就是将重定向发送回浏览器。不知道你用的是哪个网络框架。在中,您只需说:

response.sendRedirect("http://www.example.com/payment/...");

中,从控制器返回以下字符串,而不是视图名称:

return "redirect:http://www.example.com/payment/...";
于 2012-04-11T19:06:55.427 回答