2017-12-03 2 views
-1

@RequestMapping이다 클라이언트 코드가 필요 나머지 API를 사용하여 삭제 작업을 수행해야 한 나머지 URL을 필요로 (값 = "/ RemoveOneSubject은"방법은 = RequestMethod.POST) 공공의 ModelAndView RemoveOneSubject은 (HttpServletRequest의 요청) 발생 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> 
+1

[mcve]를 읽고 적절하게 질문을 수정하십시오. 힌트 : 미리보기 창은 이유가 있습니다. 우리는 문제 해결에 많은 시간을 할애하여 잘 정리 된 포괄적 인 질문을 작성하는 데 시간을 투자하시기 바랍니다. – GhostCat

답변

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 

희망 사항이 도움이 되길 바랍니다.

+0

jsp 페이지에서 하나의 행을 삭제하려면 나머지 url을 사용해야합니다. jsp에서 필요한 변경 사항은 무엇입니까? – user3578232