Restful web-service Issue,GET方法正在运行,但POST方法响应没有路径资源

时间:2017-03-13 13:34:59

标签: java rest spring-mvc hybris

我已经使用开箱即用的扩展功能在我的Hybris 6.3(4.3版春季)中实现了一个安静的网络服务。

以下是我的控制器代码: -

@Controller
@RequestMapping(value = "/{baseSiteId}/dealer")
public class DealerController extends BaseController {

    @RequestMapping(method = RequestMethod.GET)
    @ResponseBody
    public DealerData getCatalogs() {
        DealerData dealerData = new DealerData();
       //my code
       ...................
       return dealerData;
    }

    @RequestMapping(method = RequestMethod.POST, consumes = "application/json")
    @ResponseBody
    public DealerData saveCatalogs(@RequestBody final DealerData dealerData) {
        //my code
        ...................
        return dealerData;
    }
}

DealerData类: -

private String uid;
private String firstName;
private String lastName;

public String getLastName() {
    return lastName;
}

public void setLastName(String lastName) {
    this.lastName = lastName;
}

public String getFirstName() {
    return firstName;
}

public void setFirstName(String firstName) {
    this.firstName = firstName;
}

public String getUid() {
    return uid;
}

public void setUid(String uid) {
    this.uid = uid;
}

我可以使用Postman / Advanced REST客户端通过GET请求访问get方法 -

  

http://localhost:9001/testcommercewebservices/v2/test-site/dealer

但无法访问POST方法 -

  

http://localhost:9001/testcommercewebservices/v2/test-site/dealer

身体原始为JSON

{
    "uid": "123",
    "firstName": "test",
    "lastName": "test"
}

1 个答案:

答案 0 :(得分:0)

您似乎尝试在实时部署中使用POST方法而不是测试

livecommercewebservices vs testcommercewebservices

test-site vs live-site