首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >阔叶API不起作用

阔叶API不起作用
EN

Stack Overflow用户
提问于 2017-08-12 15:36:29
回答 1查看 452关注 0票数 0

我正在尝试使用Broadleaf来创建购物车、添加项目和在消费者应用程序上签出。克隆演示应用程序并按照链接:https://www.broadleafcommerce.com/docs/core/current/broadleaf-concepts/rest/rest-tutorials修改配置

问题: 1.创建新的购物车-> POST:http://localhost:8080/api/v1/cart异常: HttpRequestMethodNotSupportedException: Request 'POST‘不支持GET请求: worked

  1. 添加产品ID: POST:http://localhost:8080/api/v1/cart/1?categoryId=1&customerId=100 http://localhost:8080/api/v1/cart/1?categoryId=1&customerId=100 Request方法'POST‘不支持GET请求,但产品没有添加。

3.在订购邮件中添加付款:如上述URL异常:"com.broadleafcommerce.rest.api.exception.BroadleafWebServicesException.queryParameterNotPresent“”:"queryParameterNotPresent“、”消息“:OrderPaymentWrapper中提到的那样,http://localhost:8080/api/v1/cart/checkout/payment?customerId=100在正文中添加了OrderPaymentWrapper

或者,请https://demo.broadleafcommerce.org/api/v2/swagger-ui.html#/按照swagger文档调用API。相同的问题,无法创建订单流。

我试图通过在本地主机https://github.com/BroadleafCommerce/DemoSite上运行相同的问题来进行调试。

请给我建议。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-08-20 15:34:14

这看起来是我们的@FrameworkController注释中一个突出的问题。我在https://github.com/BroadleafCommerce/Issues/issues/3开了一期“阔叶树”杂志,更多地了解了为什么它现在失败了。

解决方法是修改API项目中的CustomCartEndpoint,您必须在createNewCartForCustomer()方法中添加该项目。CustomCartEndpoint的最终实现应该如下所示:

代码语言:javascript
运行
复制
@RestController
@RequestMapping(value = "/cart",
            produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
public class CustomCartEndpoint extends CartEndpoint {

    @Override
    @RequestMapping(value = "", method = RequestMethod.GET)
    public OrderWrapper findCartForCustomer(HttpServletRequest request) {
        try {
            return super.findCartForCustomer(request);
        } catch (Exception e) {
            // if we failed to find the cart, create a new one
            return createNewCartForCustomer(request);
        }
    }

    @Override
    @RequestMapping(value = "", method = RequestMethod.POST)
    public OrderWrapper createNewCartForCustomer(HttpServletRequest request) {
        return super.createNewCartForCustomer(request);
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45652009

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档