我需要一个REST URL我需要执行使用REST API我需要客户端代码我的代码是这样

我需要一个REST URL我需要执行使用REST API我需要客户端代码我的代码是这样

问题描述:

@RequestMapping删除操作(值=“/ RemoveOneSubject”,方法= RequestMethod.POST) 公共的ModelAndView RemoveOneSubject(HttpServletRequest的请求)抛出IOException异常{我需要一个REST URL我需要执行使用REST API我需要客户端代码我的代码是这样

 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> 
+1

请阅读[mcve]并相应地提高您的问题。并提示:预览窗口存在的原因。您希望我们花时间帮助您解决问题,因此您请花时间编写格式良好的人性化问题。 – GhostCat

进行删除。在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 

希望它会帮。

+0

我需要使用rest url执行从jsp页面删除一行在jsp中需要哪些更改 – user3578232