代码之家  ›  专栏  ›  技术社区  ›  Sridhar C

Broadleaf API不工作

  •  0
  • Sridhar C  · 技术社区  · 8 年前

    克隆了演示应用程序,并根据以下链接修改了配置: https://www.broadleafcommerce.com/docs/core/current/broadleaf-concepts/rest/rest-tutorials

    问题: 职位: http://localhost:8080/api/v1/cart 异常:HttpRequestMethodNotSupportedException:不支持请求方法“POST” 使用GET请求:已工作

    1. 添加产品ID: http://localhost:8080/api/v1/cart/1?categoryId=1&customerId=100 异常:HttpRequestMethodNotSupportedException:不支持请求方法“POST”

    3、向订单中添加付款 职位: http://localhost:8080/api/v1/cart/checkout/payment?customerId=100 如上述URL所述,在正文中添加了OrderPaymentWrapper messageKey“:“queryParameterNotPresent”, “message”:“com.broadleafcommerce.rest.api.exception.broadleavewebservicesexception.queryParameterNotPresent”

    https://demo.broadleafcommerce.org/api/v2/swagger-ui.html#/ 同一问题,无法创建订单流。

    我尝试在本地主机上运行调试 https://github.com/BroadleafCommerce/DemoSite 同样的问题。

    1 回复  |  直到 8 年前
        1
  •  0
  •   phillipuniverse    8 年前

    这似乎是我们的一个悬而未决的问题 @FrameworkController 注释。我在Broadleaf上发表了一篇文章 https://github.com/BroadleafCommerce/Issues/issues/3 提供了更多信息,了解其目前失败的原因。

    CustomCartEndpoint 在API项目中,您必须在 createNewCartForCustomer() CustomCartEndpoint 应该如下所示:

    @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);
        }
    }