Когда я в корзине. jsp нажмите кнопку очистки, выдав эту ошибку -> angular. js: 13565 УДАЛИТЬ http://localhost: 8080 / rest / cart / D79B4033A5B442A3EDA7CEBF932F9BBE 403.
И когда я нажимаю кнопку Заказать сейчас, ничего не происходит.
Я всюду искал ошибку, но не смог ее найти.
Можете ли вы мне помочь !!
это моя ошибка видео: https://youtu.be/DU_OOZxyEV0
контроллер. js
cartApp.controller("cartCtrl", function($scope,$http){
$scope.refreshCart = function (cartId) {
$http.get('/rest/cart/'+$scope.cartId).then(function (data) {
$scope.cart=data;
});
};
$scope.clearCart=function(){
$http.delete('/rest/cart/'+$scope.cartId).then($scope.refreshCart($scope.cartId));
};
$scope.initCartId=function(cartId){
$scope.cartId=cartId;
$scope.refreshCart(cartId);
};
$scope.addToCart=function(productId){
$http.put('/rest/cart/add/'+productId).then(function(data){
$scope.refreshCart($http.get('/rest/cart/cartId'));
alert("product successfully added to the cart")
});
};
$scope.removeFromCart=function(productId){
$http.put('/rest/cart/remove/'+productId).then(function(data){
$scope.refreshCart($http.get('/rest/cart/cartId'));
alert("product successfully removed from the cart")
});
};
});
корзина . jsp
<section class="container" ng-app="cartApp">
<div ng-controller = "cartCtrl" ng-init="initCartId('${cartId}')">
<div>
<a class="btn btn-danger pull-left" ng-click="clearCart()"><span class="glyphicon glyphicon-remove-sign"></span>Clear Cart </a>
</div>
<table class="table table-hover">
<tr>
<th>Product</th>
<th>Unit Price</th>
<th>Quantity</th>
<th>Price</th>
<th>Action</th>
</tr>
<tr ng-repeat="item in cart.cartItems">
<td>{{item.product.productName}} </td>
<td>{{item.product.productPrice}}</td>
<td>{{item.quantity}}</td>
<td>{{item.totalPrice}}</td>
<td><a href="#" class="label label-danger" ng-click="removeFromCart(item.product.productId)">
<span class="glyhicon glyhicon-romove">Remove</span></a></td>
</tr>
<tr>
<th></th>
<th></th>
<th>Grand Total: </th>
<th>{{cart.grandTotal}}</th>
<th></th>
</tr>
</table>
<a href="<spring:url value="/productList"/> " class="btn btn-default">Continue Shopping</a>
</div>
</section>
product. jsp
<p ng-controller="cartCtrl">
<a href="#" class="btn btn-warning btn-large"
ng-click="addToCart('${product.productId}')">
<span class="glyphicon glyphicon-shopping-cart"></span>Order Now</a>
</p>
Pom. xml
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>4.0.4.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-web -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>4.0.4.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-config -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>4.0.4.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-taglibs -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>4.0.4.RELEASE</version>
</dependency>