1

hello i'm using spring boot , restful web service and angularjs,

this is my restControlleur

@RestController
@RequestMapping("/structure")
public class StructureNotificationRestContolleur {

 @Autowired
 StructureNotificationService StructureNotif;
 @Autowired
 ChampService champService;

 @RequestMapping(value = "/deleteChamp/{ch}", method=RequestMethod.DELETE )
    public @ResponseBody void DeleteChamp(@PathVariable (value="ch") int ch) 
    {
     champService.DeleteChamp(ch);
    }

there is the button to delete :

$scope.deleteST= function(ids)
            {
                 $http.delete('/structure/deleteChamp/'+ids).
                 success(function(data) {
                     alert(ids);

                 });

            }

but there is the error : o.s.web.servlet.PageNotFound : Request method 'DELETE' not supported

???

r007
  • 305
  • 1
  • 2
  • 17
majed ben ali
  • 31
  • 1
  • 7
  • and what is `'/structure/deleteChamp/'+ids` ? does it exist ? – Pogrindis Apr 17 '15 at 10:41
  • /structure/deleteChamp/ it's the path of the rest methode to delete and the "ids" is the id of the element to be deleted ??? – majed ben ali Apr 17 '15 at 10:46
  • i think that spring boot don't know method 'DELETE' ??? Request method 'DELETE' not supported – majed ben ali Apr 17 '15 at 10:47
  • Can you try test just the service? I think that when you are calling the service from angularjs you are not telling which method is. – Eddú Meléndez Apr 17 '15 at 19:18
  • when i delete the method=RequestMethod.DELETE from my RestControlleur class and iwritting this line in the bar address http://localhost:8080/structure/deleteStruct/AE, it work !!!!!!!!!!!!!!!!! the field with id "AE" was deleting – majed ben ali Apr 18 '15 at 11:08

1 Answers1

0
$scope.deleteST= function(ids)
        {
             $http.delete('/structure/deleteChamp/', ids).
             success(function(data) {
                 alert(ids);

             });

        }

Edit*** Clarificaction: The + paramether works as addition meaning you are gonna end up with a STRING as result of the operation while the "," paramether means you are gonna end up with a string the url plus the javascript/Json object you need.

Try using a "," instead of the "+"

r007
  • 305
  • 1
  • 2
  • 17
  • While this code may answer the question, it would be better to explain how it solves the problem without introducing others and why to use it. Code-only answers are not useful in the long run. – JAL Dec 01 '15 at 19:42