前段时间项目中经常遇到一些a标签的onclick时间的传参问题
提示些 is not defined 问题:
源码如下:
<td>${login}</td>
<td><span class="zh">${name_zh}</span></td>
<td><span class="en">${name_en}</span></td>
<td>${email}</td>
<td>${phone}</td>
<td>${created_at}</td>
<td>${updated_at}</td>
<td>${admin_note}</td>
<td>
<div class="btn-group">
<a href="showUsers.action?id=${id}" class="btn btn-default"> <span class="glyphicon glyphicon-eye-open"></span>view </a>
<a href="editUsers.action?id=${id}" class="btn btn-primary"> <span class="glyphicon glyphicon-edit"></span> Edit</a>
<a href="destroyUsers.action?id=${id}" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span> Del</a>
<a href="javascript:void(0);" onclick="unbindPhone(${id },${login },${phone })" class="btn btn-warning"><span class="glyphicon glyphicon-plane"></span>unbind</a>
</div>
</td>
这是因为 在
onclick="unbindPhone(${id },${login },${phone })"
代码中 JSP将${login }等参数当成了变量,所以会报没有undefined的错误
加上单引号就OK了
onclick="unbindPhone('${id }','${login }','${phone }')"