2017-01-30 2 views
0

Ich habe ein Projekt im Spring Web Modell-View-Controller (MVC) Framework. Die Version der Spring Web Model-View-Controller (MVC) Framework 3.2.8 auf einer WebLogic Server Version eingesetzt: 12.1.2.0.0DELETE Representational State Transfer im Frühjahr MVC

Ich habe dieses Stück Code in meinem JSP

<button id="deleteImageButtonId165850" class="btn btn-primary" type="submit" >Delete Image</button> 
<script> 
$('#deleteImageButtonId165850').click(function(){$('#serviceFormId').attr('action', 'http://127.0.0.1:7001/devices/newdesign/manage/application/service/image/del/165850'); 
$('#serviceFormId').attr('method', 'delete');}); 
</script> 

und mein Controller

@RequestMapping(value = { "/newdesign/manage/application/service/image/del/{imageId}", 
           "/newdesign/manage/application/service/image/del/{imageId}/" }, method = { RequestMethod.DELETE }) 
    public String deleteServiceImage(@ModelAttribute("serviceForm") ServiceForm serviceForm, @PathVariable Long imageId, 
            HttpServletRequest request, Model model) throws Exception { 
.. 
} 

Aber wenn ich in der Schaltfläche klicken, bekam ich einen followin

Request method 'GET' not supported 

Antwort

0

HTML-Formulare unterstützen nur GET und POST. Sie müssen die DELETE in JavaScript tun.

0

-Test g code

@RequestMapping(value = { "/newdesign/manage/application/service/image/del/{imageId}", 
           "/newdesign/manage/application/service/image/del/{imageId}/" }, method = { RequestMethod.POST }) 
    public String deleteServiceImage(@ModelAttribute("serviceForm") ServiceForm serviceForm, @PathVariable Long imageId, 
            HttpServletRequest request, Model model) throws Exception { 
.. 
}