ModelMap and @Controller in spring webflow

396 Views Asked by At
  1. Is there something like ModelMap in spring webflow ?
  2. In spring webflow I would like to put multiple objects into map under different keys and then display them in jsp page. How should I do it ?
  3. How can I get @Controller functionality in spring webflow - preparing data for jsp page?
1

There are 1 best solutions below

1
On

1.) More read here

ModelMap subclasses LinkedHashMap.

addAttribute can be called with just a value, and the map key is then inferred from the type.

The addAttribute methods all return the ModelMap, so you can chain method called together, e.g. modelMap.addAttribute('x', x).addAttribute('y',y)

The addAttribute methods checks that the values aren't null

The generic type of ModelMap is fixed at Map<String, Object>, which is the only one that makes sense for a view model.

2.) Need to access ModelMap values through expression language

// At controller layer

modelMap.put("result",myResult);

/At Jsp layer

<html>
  <head>
   <title></title>
  </head>

<body>
  <div align="center">
    <h1>{result}</h1>
  </div>
</body>

3.) The @Controller annotation is used to mark any java class as a controller class. Also you can add <mvc:annotation-driven /> for enabling the Spring MVC annotations.

detailed information here