我已经使用开箱即用的扩展功能在我的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"
}
答案 0 :(得分:0)
您似乎尝试在实时部署中使用POST
方法而不是测试
livecommercewebservices
vs testcommercewebservices
和
test-site
vs live-site