I add an attribute to my ModelAndView
in spring and then forward it to my thymeleaf view.
In the view, I have the following code:
<script th:inline="javascript"> /*<![CDATA[*/ var applicationName = /*[[${T(com.sample.constants.ApplicationConstants).MODEL_ATTR_COLLECTED_VALUES}]]*/ "Test"; var collectedValueJson = [[${collectedValues}]]; console.log(collectedUserJson); /*]]>*/ </script>
The result of this is
var applicationName = 'collectedValues'; var collectedUserJson = '[{\"givenname\":\"Muster\",\"surname\":\"Peter\"}]';
It's good. Now my desire is that I can take the var application
and get the modelattribute attribute with this variable, but this does not work.
Result:
var tmp2 = ${applicationName};
Another attempt was that I have access to the model attribute with the syntax /*[[ ]]*/
on the first try:
var applicationName = ${/*[[${T(com.sample.constants.ApplicationConstants).MODEL_ATTR_COLLECTED_VALUES}]]*/};
But the result will be:
var tmp = ${'collectedValues'
I have no idea what I can try.
Any other suggestions?
Thanks in advance.
source share