0

My biggest problem about this question is I do not quite know how to phrase it. In javascript, if a delete button is called it runs the following function

$scope.delete = function(){
            var params = {
                username: 'thisGuy'
            };
            $http.delete(afHttp.baseUrl, params)
                .success(function(data) {
                });
    }

while in spring I have

@DELETE
@Path("/{blah}")
public void getDeleteMssg(@RequestBody Person userName) throws Exception {
    dao.delete(userName);
}

and an interface that

@Delete("delete from People where userName = #{userName}")
void delete(Person userName) throws Exception;

Here is my problem. When I do this, in my chrome console, I get the error 415 (Unsupported Media Type). And if I change my javascript to be $http.post(afHttp.baseUrl, params) it uses my add function on spring (instead of delete) and adds another username to the server which is not right. Can someone help me figure this out, or at least a good search word to find myself. Thanks.

4

1 回答 1

0

您是否检查过您收到的错误是在从控制器的 delete 方法返回调用之后,还是在请求您删除 url 时?

也尝试将此注释添加到您的删除方法

 @ResponseStatus(HttpStatus.NO_CONTENT)
于 2013-11-07T09:40:09.507 回答