@RequestMapping(value =" / RemoveOneSubject",method = RequestMethod.POST) public ModelAndView RemoveOneSubject(HttpServletRequest request)抛出IOException {
ModelAndView model = new ModelAndView("RemoveOneSubject");
final String uri = "http://localhost:8080/subject/api/remove/{id}";
String id = request.getParameter("id");
RestTemplate restTemplate = new RestTemplate();
restTemplate.delete (uri,id);
model.addObject("theSubject", id);
return model;
enter code herejsp is
删除
<table id="myTable" class="table table-striped">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Created by</th>
<th>Created time</th>
</td></th>
</tr>
</thead>
<tbody>
<c:if test="${not empty theSubject}">
<c:forEach var="listValue" items="${theSubject}">
<tr>
<td><input type="checkbox" name="chkBox"></td>
<td><a href=""><c:out value="${listValue.name}" /></a></td>
<td><c:out value="${listValue.createdBy}" /></td>
<td><c:out value="${listValue.createTime}" /></td>
<td><c:out value="${listValue.studentID}"></c:out></td> </tr>
</c:forEach>
</c:if>
</tbody>
</table>
答案 0 :(得分:0)
删除。在RestController中已经有删除方法。您实际上可以使用获取方法来实现简单方法,而不是最佳实践。但是,您可以使用此代码删除整个控制器中的内容。
@RestController
@RequestMapping(value = "/api")
public class ApiCodeController {
@RequestMapping(method = RequestMethod.GET, value = "/delete")
public string DeleteSomething(@RequestParam(required = false) String email)
{
//Do Something with your code to delete an object
}
}
你只需要打电话。
/api?delete=your-parameter
希望它会有所帮助。