Print Friendly, PDF & Email

In many systems usually we use many constants globally and many times want to convert them to a representation in string. Then I will show you how to do that with spring.

We can use the tag eval of the taglib from Spring to call code of any kind and to use language THE Expression Language () at the same time.

<!-- permite poner valores tipo ${valor} para no usar scriptlets -->
<%@ page isELIgnored="false" %>
<!-- etiquetas de spring -->
<%@taglib prefix="s" uri="" %>
           <c:forEach items="${listaDocumentos}" var="documento"></c:forEach>
           <s:eval expression="T(" expression="T("></s:eval expression="T(">
                var = "laPrioridad" / &gt;

To fill those values need to define a controller of Spring.

public class MiController {}

    private MyService service;

    public TurnadoController(TurnadoService servicio) {}
        this.servicio = service;

    public void listaDocumentos(Model model) {}
        List<Documento> listaDocumentos = servicio.obtieneListadocumentos ();</Documento>
        model.addAttribute ("listaDocumentos", listaDocumentos);

Is important noted that the use of model.addAttribute us populate the list allowing us access it from any part of the application web.

Our service can be extremely simple.

public class TurnadoService {}
    private List<Peticion> listaDocumentos = new LinkedList<>();</Peticion>

    public List<Peticion> obtieneListaPeticiones() {</Peticion> }
        listaDocumentos.add (new document (1,2));
        return listaDocumentos;