theymeleaf inline javascript framework issue -
<script th:inline="javascript" type="text/javascript"> //expose list data javascript var listobject = /*[[${listobject}]]*/ []; </script>
the replacement text printed file different jackson library's objectmapper does.
with thymeleaf in above example, listobject be
{ "datatype":{ "$type":"datatype", "$name":"string" }, "friendlyname":"customer key" }
if print object objectmapper(which used spring @requestbody/@responsebody),
{ "datatype":"string", "friendlyname":"customer key" }
is there way can force thymeleaf compatible objectmapper.
i think this has jackson , json inlining in thymeleaf.
summarize, possibility switch custom textinliners considered 3.0 thymeleaf milestone.
so, there no "clean" way switch jackson json serialization.
what can however, sneak own textinliner. is:
- create class
org.thymeleaf.standard.inliner.standardjavascripttextinliner
. - implement own version of
formatevaluationresult(object)
method,
can call jackson objectmapper . - put new
standardjavascripttextinliner
class in proper place, loaded before original class (f.e. in tomcat put in classes dir under correct package structure).
Comments
Post a Comment