求助:怎么根据id删除数据,而controller和jsp传递参数问题?
/**删除*/functiondeleteXxfk(id){alert(id);window.location.href="${ctx}/xxfk/delete_xxfk...
/**删除*/
function deleteXxfk(id) {
alert(id);
window.location.href = "${ctx}/xxfk/delete_xxfk?id="+id;
}
<div style="padding:10px">
<form action="${ctx }/xxfk/xxfk_list" id="searchForm" method="post">
标题:
<input type="text" class="form-control" name="title" value="${serArgs.serTitle}" placeholder="请输入标题" style="display:inline-block; width:120px">
<button type="button" class="btn btn-success yogurt_search_button" data-target="#myModal2" data-toggle="modal" style="margin-left:10px" onclick="search();">
<img src="${ctx }/yogurtResource/images/Panel/search.png" width="18" height="18" />
</button>
<button type="button" class="btn btn-success" onclick="openXxfk();">打开新增页面</button>
<button type="button" class="btn btn-success" onclick="deleteXxfk(${xxfk.id });">删除</button>
</form>
</div>
<div class="yogurt_elementsbox_core clear">
<div class="yogurt_elementsbox_table_article" id="yogurt_elementsbox_table_article">
<table id="tableBody" class="table yogurt_elementsbox_table">
<thead>
<tr class="yogurt_tab_back" onmouseover="this.className='yogurt_tab_trhover'" onmouseout="this.className='yogurt_tab_back'">
<th>
<input type="checkbox" onclick="checkAll(this);">
</th>
<th>序号</th>
<th>标题</th>
<th>内容</th>
<th> </th>
</tr>
</thead>
<tbody id="xxfk">
<c:forEach var="xxfk" items="${lstXxfks}" varStatus="status">
<tr>
<td>
<input type="checkbox" value="${xxfk.id }">
</td>
<td>${status.count}</td>
<td>${xxfk.title }</td>
<td>${xxfk.contents}</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</div>
</div>
Java中代码
/**
*删除信息
*/
@RequestMapping("delete_xxfk")
public String deleteXxfk(String id) throws Exception{
String address = "redirect:/xxfk/xxfk_list";
System.out.println(id);
xxfkService.deleteById(Long.valueOf(id));
return address;
} 展开
function deleteXxfk(id) {
alert(id);
window.location.href = "${ctx}/xxfk/delete_xxfk?id="+id;
}
<div style="padding:10px">
<form action="${ctx }/xxfk/xxfk_list" id="searchForm" method="post">
标题:
<input type="text" class="form-control" name="title" value="${serArgs.serTitle}" placeholder="请输入标题" style="display:inline-block; width:120px">
<button type="button" class="btn btn-success yogurt_search_button" data-target="#myModal2" data-toggle="modal" style="margin-left:10px" onclick="search();">
<img src="${ctx }/yogurtResource/images/Panel/search.png" width="18" height="18" />
</button>
<button type="button" class="btn btn-success" onclick="openXxfk();">打开新增页面</button>
<button type="button" class="btn btn-success" onclick="deleteXxfk(${xxfk.id });">删除</button>
</form>
</div>
<div class="yogurt_elementsbox_core clear">
<div class="yogurt_elementsbox_table_article" id="yogurt_elementsbox_table_article">
<table id="tableBody" class="table yogurt_elementsbox_table">
<thead>
<tr class="yogurt_tab_back" onmouseover="this.className='yogurt_tab_trhover'" onmouseout="this.className='yogurt_tab_back'">
<th>
<input type="checkbox" onclick="checkAll(this);">
</th>
<th>序号</th>
<th>标题</th>
<th>内容</th>
<th> </th>
</tr>
</thead>
<tbody id="xxfk">
<c:forEach var="xxfk" items="${lstXxfks}" varStatus="status">
<tr>
<td>
<input type="checkbox" value="${xxfk.id }">
</td>
<td>${status.count}</td>
<td>${xxfk.title }</td>
<td>${xxfk.contents}</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</div>
</div>
Java中代码
/**
*删除信息
*/
@RequestMapping("delete_xxfk")
public String deleteXxfk(String id) throws Exception{
String address = "redirect:/xxfk/xxfk_list";
System.out.println(id);
xxfkService.deleteById(Long.valueOf(id));
return address;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询