0

Here(Controller) I add an attibute to my model

@RequestMapping("/archivosProcesados")
public String archivosProcesados(final ModelMap model) {
    model.addAttribute("allfiles", filestorageService.getAllFiles());
    return "archivosprocesados";
}

and in my view I access to them via Thymeleaf like this

            <tr th:each="ap: ${archivos}">
                <td th:text="${ap.clave_documento}"></td>
                <td th:text="${ap.tipo_documento}"></td>
                <td th:text="${ap.nombre_documento}"></td>
                <td th:text="${ap.fecha_procesamiento}"></td>
            </tr>

so I want to access to same values in my javaScript code, but how to do it? Thanks

1 Answers1

0

To do that Convert Java object to JSON string and pass it to thymeleaf and you will get the javascript object directly.

Refer this How to access model attribute in Javascript

and

https://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#script-inlining-javascript-and-dart

Alien
  • 15,141
  • 6
  • 37
  • 57