maanantai 6. heinäkuuta 2009

Spring controller and redirecting

Two ways to use redirecting. First one uses the url mapping configured in an xml file. The url seems to be the same for the client (or actually is, depends on the situation). The second one tells the client to redirect to a certain page, so the url in the client changes accordingly.

1. Use the Spring url mapping
Map model = new HashMap();
model.put("article_id", "get it from db?");
return new ModelAndView("article", model);


2. Tell the client to go to a certain page
return new ModelAndView(new RedirectView("index.jsp"));

Ei kommentteja:

Lähetä kommentti

Huomaa: vain tämän blogin jäsen voi lisätä kommentin.