Escaping HTML in a Java Play Framework Scala Templ

2020-06-20 05:01发布

Using a Scala template within the Java Play framework 2.0, I want to output dynamic content as HTML encoded.

For example:

<script type="text/javascript">
    $("#@field.getId()").fieldList({
        data: "@myUnencodedData"
    })
</script>

Are there built in methods to accomplish this?

1条回答
家丑人穷心不美
2楼-- · 2020-06-20 05:26

By default, HTML is escaped for security reasons. To output HTML, you wrap it in the Html helper: @Html(myUnencodedData).

查看更多
登录 后发表回答