こんにちは私は、jQueryデータ関数を使用してdivにデータを関連付けるJSPタグ内に生成されたコードをいくつか持っています。uuidを削除するリファクタリングコード
私はUUIDを使用して、ページ上のdivにjQueryスクリプトをリンクしています。 しかし、このアプローチは醜く不便です。UUIDを必要としないようにリファクタリングする方法があるのかどうか疑問に思っていました。
コードは次のようになります。
for(DomainObject domainObject : domainObjects){
//...
String uuid = UUID.randomUUID().toString();
out.println("<div id='" +uuid + "' class='" + divClass + "'>");
// Write out the details of this domain object.
out.println(/*...*/);
// Associate data with the div
out.println("<script type='text/javascript'>$('#"+uuid+"').data('domainObject'," + jsonSerializer.exclude("class").serialize(domainObject) + ")</script>");
out.println("</div>");
//...
}
を、あなたのjsの内部に完全なドメインオブジェクトが必要なのでしょうか? –