2014-09-01 105 views
0

我有一个以.json功能,其获取一些数据,我想用一个<display:table>显示它,我该怎么办呢如何在显示中显示数据:.json函数中的表格?

Alerta.js

function loadAlertaCitas(){ 
    $.ajax({ 
     type: "GET", 
     url: contextpath+"/alerta/cargaAlertas.json", 
     contentType: "application/json; charset=utf-8", 
     dataType: "json", 
     success: function(data) { 
      listaAlertas = data; 
     } 
    }); 
} 

Alerta.jsp

<display:table name="listaAlertas" id="alertas" 
           defaultorder="descending" requestURI="/other/listaAlertas" pagesize="12" 
           class="table table-striped table-condensed"> 

           <display:column property="fechaalta" titleKey="label.fechaAlta" 
            sortable="true" class="ancho90" /> 

          </display:table> 
+0

为什么你有'的contentType: “应用/ JSON的;字符集= UTF-8”,在'GET请求? GET请求中没有请求主体,因此没有任何内容类型可以描述。 – Quentin 2014-09-01 08:07:59

回答

0

JSP在服务器上执行。 JavaScript(在这种情况下)在浏览器中执行。

您无法使用JavaScript生成JSP标记,因为将它们转换为HTML的软件存在于错误的计算机上。

您需要改为在浏览器中操作文档的DOM。使用createElementcreateTextNode,appendChildfriends

0

你可以在服务器端做到这一点。阅读渲染方法中的JSON文件和负载display:table为JSP模板:

request.setAttribute('listaAlertas', jsonData);

More info

如果你坚持从浏览器动态加载,你需要按照建议操纵dom。在这种情况下,您不能在服务器上呈现display:table

More info