href 中的意外标识符
Unexpected identifier in a href
我想在 <a href.. >
的 onclick 方法中调用 AJAX 函数,但我不能。
有问题的代码如下:
<div class="container" id="<portlet:namespace/>tabla">
<table class="noticias-table">
<thead>
<tr class="thead-agregador">
<th scope="col">Imagen</th>
<th scope="col">Fecha</th>
<th scope="col">Categoría</th>
<th scope="col">Titular</th>
<th scope="col">Estado</th>
<th scope="col">Opciones</th>
</tr>
</thead>
<tbody>
<c:forEach var="contenido" items="${Contenidos}">
<fmt:formatDate pattern="dd/MMM/yyyy" value="${contenido.fecha}"
var="formatFecha" />
<tr>
<td class="td-contenido"><img src="${contenido.imagen}"
class="td-contenido-img" /></td>
<td class="td-contenido">${formatFecha}</td>
<td class="td-contenido">${contenido.categoria}</td>
<td class="td-contenido"><a id="tituloContenido" href="#"
onclick="openNews(${contenido.articlePrimKey}); return false">${contenido.titulo}</a>
</td>
<td class="td-contenido">${contenido.status}</td>
<td class="td-contenido">Opciones rellenar</td>
</tr>
</c:forEach>
</tbody>
</table>
<a id="Ultimas" href="#" onclick="sortByLast(${Contenidos}); return false">Ultimas</a>
</div>
我想传递给控制器的变量 "Contenidos" List<PersonalBean>
,使用浏览器的开发者工具我可以看到列表在 <a>
中的格式正确调用,但是当我点击它时,出现未捕获错误并且脚本方法没有开始执行
如果我去掉onclick这个方法,错误就消失了,那句话错在哪里?
我猜这是一个模板语法,你要用字符串替换它,所以你需要引号
sortByLast('${Contenidos}');
我想在 <a href.. >
的 onclick 方法中调用 AJAX 函数,但我不能。
有问题的代码如下:
<div class="container" id="<portlet:namespace/>tabla">
<table class="noticias-table">
<thead>
<tr class="thead-agregador">
<th scope="col">Imagen</th>
<th scope="col">Fecha</th>
<th scope="col">Categoría</th>
<th scope="col">Titular</th>
<th scope="col">Estado</th>
<th scope="col">Opciones</th>
</tr>
</thead>
<tbody>
<c:forEach var="contenido" items="${Contenidos}">
<fmt:formatDate pattern="dd/MMM/yyyy" value="${contenido.fecha}"
var="formatFecha" />
<tr>
<td class="td-contenido"><img src="${contenido.imagen}"
class="td-contenido-img" /></td>
<td class="td-contenido">${formatFecha}</td>
<td class="td-contenido">${contenido.categoria}</td>
<td class="td-contenido"><a id="tituloContenido" href="#"
onclick="openNews(${contenido.articlePrimKey}); return false">${contenido.titulo}</a>
</td>
<td class="td-contenido">${contenido.status}</td>
<td class="td-contenido">Opciones rellenar</td>
</tr>
</c:forEach>
</tbody>
</table>
<a id="Ultimas" href="#" onclick="sortByLast(${Contenidos}); return false">Ultimas</a>
</div>
我想传递给控制器的变量 "Contenidos" List<PersonalBean>
,使用浏览器的开发者工具我可以看到列表在 <a>
中的格式正确调用,但是当我点击它时,出现未捕获错误并且脚本方法没有开始执行
如果我去掉onclick这个方法,错误就消失了,那句话错在哪里?
我猜这是一个模板语法,你要用字符串替换它,所以你需要引号
sortByLast('${Contenidos}');