0

I noticed that when a Form Submit happens, my handler method that captures a @Model object as a parameter does have a valid Model available to me, e.g.

public ModelAndView save(final HttpServletRequest request, 
             @ModelAttribute(MODEL_NAME) MyModel model,
             BindingResult bindingResult)

But when I have a handler method corresponding to a URL redirect from a simple <a href=".."> button/link, e.g.

<a href="myController.do&function=add">

leading to

@RequestMapping(params = "function=add")
public ModelAndView add(final HttpServletRequest request, 
          @ModelAttribute(MODEL_NAME) MyModel model) throws Exception 

in that case, the model object is NULL. The model wasn't carried through the request and made available to me in the handler method.

Is there a way to reexpose the model? I do have the same param in both methods, but in the 2nd one the "model" object is NULL.

gene b.
  • 10,512
  • 21
  • 115
  • 227

1 Answers1

0

If you want to use GET request with you will need to add the model to the URL. Or you can use POST with a form instead.

See: how to pass a java object from jsp to spring controller on clicking a link

Community
  • 1
  • 1
BARJ
  • 1,543
  • 3
  • 20
  • 28