In a Spring Controller method, I want to enrich the Model elements from what is posted from the jsp file.
Here is the start of the code function. the model is void everytime the function is entered. Any Hint about that?
@RequestMapping(value = Uris.IMPORTADDRBOOK)
public String mainImportController(HttpServletRequest request, HttpServletResponse response, Model model,
@RequestParam(value = "chosenSP", required = false) String bookToImportName,
@RequestParam(value = "catMode", required = false) String catMode,
@RequestParam(value = "transition", required = false) ImportControllerTransitions transition) {
logger.debug(String.format("controller import. Etat entrée : %s, transition demandée : %s, chosen SP : %s, catmode : %s",
model.asMap().get("importState"), transition, bookToImportName, catMode));
logger.debug(String.format("Modele Entree Import Controller:"));
for (String attribute : model.asMap().keySet())
logger.debug(String.format("%s : %s", attribute, model.asMap().get(attribute)));
if (!model.containsAttribute("importState"))
model.addAttribute("importState", ImportControllerState.INITIAL);
switch ((ImportControllerState) model.asMap().get("importState")) {
case INITIAL:
if (transition == ImportControllerTransitions.CONNECTORCHOICE) {
model.addAttribute("importState", ImportControllerState.CONNECTOR);
if (bookToImportName != null)
model.addAttribute("chosenSP", DynAddrBookTypes.valueOf(bookToImportName));
}
break;
default:
break;
}
logger.debug(String.format("Modele sortie Import Controller:"));
for (String attribute : model.asMap().keySet())
logger.debug(String.format("%s : %s", attribute, model.asMap().get(attribute)));
return Uris.IMPORTADDRBOOK;
}
The JSP can read correctly the model attribute but when I come back into the controller, model is empty again... Thanks in advance,