【发布时间】:2019-04-08 04:50:32
【问题描述】:
我有一个带有控制器的 Spring Boot API(无状态),它接收 POST 请求,提取 POST 请求的参数以通过 GET 将它们发送到我的 Angular 客户端。我的问题是是否可以在 HttpServletResponse.sendRedirect() 中发送隐藏参数?
目前我有的是这个,但我不想在浏览器中显示参数...
@RequestMapping(value = "/return", method = RequestMethod.POST, headers = "Accept=text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8")
@ResponseBody
@Transactional
public void returnData(UriComponentsBuilder uriComponentsBuilder, final HttpServletRequest request,
final HttpServletResponse response) throws IOException {
String parameter=request.getParameter("billCode");
response.sendRedirect("http://localhost:4200/payment?parameterOne="+parameter);
}
更新:
我不能使用HttpSession session = request.getSession(false); 然后session.setAttribute("helloWorld", "Hello world") 因为session 是Null
非常感谢!
【问题讨论】:
标签: java http spring-boot controller