[英]How to pass HttpServletRequest from one controller to other
I have a problem statement where I need to pass HttpServletRequest from one controller to another so that I can extract the Authorization header in another controller.我有一个问题声明,我需要将 HttpServletRequest 从一个 controller 传递到另一个,以便我可以在另一个 controller 中提取授权 header。 Any lead appreciated please let me know how I can pass it through feign client API request and How I accept it in another controller.任何领导赞赏请让我知道如何通过假装客户端 API 请求传递它,以及如何在另一个 controller 中接受它。
Thanks in advance.提前致谢。
This is the simple example that how you will pass the Httprequest from one controller to other controller.这是一个简单的示例,说明如何将 Httprequest 从一个 controller 传递到另一个 controller。
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.MULTIPART_FORM_DATA);
MultiValueMap<String, Object> form = new LinkedMultiValueMap<>();
form.add("name", request.getParameter("name"));
form.add("abc", request.getParameter("abc"));
form.add("xyz", request.getParameter("xyz"));
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(form, httpHeaders);
restTemplate.postForEntity("http:localhost:8080/save", requestEntity, String.class);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.