I have an application that entertains a POST
request. To request, I need to define some headers, boundaries and hyphens. In other words, I need to craft the complete request. Which I did successfully using HttpURLConnection
.
Now, I want to request the application from my Spring application.
Say, I have three applications A(sensor), B(spring) and C(server).
In this case, B will act as a bridge which receives the request from A authenticate it and send it to the C.
I don't want to craft the same request again in Spring it just redirect the request to the server. Is there any mechanism in Spring for this?
A request can be basically processed in three ways: a) resolved by Spring in a controller action, b) forwarded to a different controller action, c) redirected to client to fetch another URL. Forward: performed internally by Spring. the browser is completely unaware of forward, so its original URL remains intact.
Try a URL http://localhost:8080/HelloWeb/index and you should see the following result if everything is fine with your Spring Web Application. Click the "Redirect Page" button to submit the form and to get the final redirected page.
We can use a name such as a redirect: http://localhost:8080/spring-redirect-and-forward/redirectedUrl if we need to redirect to an absolute URL.
@RestController public class RedirectController { @RequestMapping("/redirect") public String redirect() { return "redirect:/other/controller/"; } } and if we will try to access that url curl localhost:8080/redirect we will simply see redirect:/other/controller/ string as result.
There are 3 mechanismes of redirection:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With