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 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thansk a lot I finally understand

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.