3

If I add an attribute to a ModelMap:

    model.addAttribute("abc", 123);

and display the view:

@RequestMapping(value = "/foo", method = RequestMethod.GET)
public final String foo(HttpServletRequest request, BindingResult bindResult, ModelMap model) {
    model.addAttribute("abc", 123);
    return "foo";
}

I see this in the browser address bar:

http://localhost:6060/foo?abc=123

Is it possible to add an attribute to the model without it showing up as query string name-value pairs? (I'm using Spring MVC 3.0)

Tyson McClure
  • 31
  • 1
  • 2
  • 2
    What view is `foo` resolving to? That URL must be from a redirect, in which case the parameter is appropriate. – skaffman May 27 '11 at 18:14

2 Answers2

2

You are probably using the @ModelAttribute annotation somewhere in your controller.
see answer to this question.

Community
  • 1
  • 1
Yoni
  • 10,171
  • 9
  • 55
  • 72
1

If you change the request method to POST then model attributes won't show up in the url, they will be mapped to form fields. But request parameters on a url are a good thing, if you make it a Post then your users can't bookmark the url. Web applications that post everything are so 1990s.

Nathan Hughes
  • 94,330
  • 19
  • 181
  • 276