3

First of all, I am using playframework 2 with Java.

I have a Bootstrap-lookahead input field in a view and I want to use a json array as source for it, as described here. I can generate json at server-side with:

Json.toJson(users)

or on client with:

@{Json.toJson(users)}

However it generates strings with " and when I try to create the bootstrap-lookahead field with this data, it gives me

Uncaught SyntaxError: Unexpected token &

Could someone help me with that?

Thank you


You can prevent escaping by using @Html(Json.toJson(users)) in template.

Docs, last paragraph

4

1 に答える 1

4

@Html(Json.toJson(users))テンプレート内で使用することで、エスケープを防ぐことができます。

ドキュメント、最後の段落

于 2012-09-12T20:49:59.193 に答える