3

I am using Spring and in my controller I have a `@ModelAttribute("params")'.

like this

@ModelAttribute("params")
public MultiValueMap<String, String> populateParams()
{


    final MultiValueMap<String, String> params = new LinkedMultiValueMap<>();

    params.add("signature", token.generate());
    params.add("params", token.generate());
    params.add("mockpayment", "true");
    params.add("req_reference_number", cartService.getSessionCart().getCode());
    params.add("reason_code", "100");
    return params;
}

this is used here in my ControllerA which is in charge to send it back to ControllerB using a POST, so in ControllerA I have a code like this :

@RequestMapping(value="/somePath", method =
{ RequestMethod.POST, RequestMethod.GET }))
public String test(final Model model, final RedirectAttributes redirectAttrs)
{       
    MultiValueMap<String, String> params = new LinkedMultiValueMap<>();


params = (MultiValueMap<String, String>) model.asMap().get("params");
...
}

What I want to do next is to send this Data structure Via a POST to ControllerB, how can I do that?

OEH
  • 665
  • 11
  • 29
  • What do you mean by *back* using *POST*? POST/GET is the method for the forward/request payload, the response is payload sent back. – Andreas Mar 14 '17 at 17:29
  • 1
    You can serialize it and send it on the POST via JSON. http://stackoverflow.com/questions/16607444/how-to-serialize-object-to-json – user681574 Mar 14 '17 at 17:30
  • @user681574 I am using the HttpPost Object and I would like to use it to send those params... I dont see a method that is "attaching" the params to the request. How should I do that? – OEH Mar 15 '17 at 10:02

0 Answers0