Spring forward with added parameters?

后端 未结 4 718
我在风中等你
我在风中等你 2020-12-01 03:57

Is there a way to forward a request to another Controller while adding some parameter data to it? I tried adding to the ModelMap, but it doesn\'t seem to hang around. I am d

4条回答
  •  广开言路
    2020-12-01 04:15

    I've found this post, that uses an HttpRequestWrapper:

    First:
    Define the HttpRequestWrapper and override the methods getParameter, getParameterMap, getParameterNames and getParameterValues like in the post.

    Second:
    Forward via RequestDispatcher to your url, using the wrapped request in the method parameters:

    request.getRequestDispatcher("myForwardUrl").forward(new MyRequestWrapper(request), response);
    

    I've tried this out for deleting of parameters (which is even more difficult!) and it works!

提交回复
热议问题