单页Web应用程序刷新按钮不受支持

时间:2015-05-26 06:22:02

标签: javascript html angularjs spring-mvc

我正在使用angularjs和spring mvc来构建一个Application,我编写了rest api,它将从后端获取数据,我使用angularjs ng-grid显示它。我的问题是,当我点击刷新按钮时,我收到响应为 HTTP状态405 - 请求方法'GET'不支持我得到此响应的原因是什么?以及如何解决这个问题?

如果我点击浏览器的刷新按钮,它应该指向我的应用程序的登陆页面。

Angular js控制器代码

function customerController($scope,$http,$window,$location,updateFactory) {

$scope.customerId;
$scope.customerEmail;
$scope.CustName;


$http.get("./getCustomer")

.success(function(response) {$scope.customers = response;});

 $scope.filterOptions = {
            filterText: ''
          };}

Spring Mvc控制器代码

@RequestMapping(value="/getCustomer" , method=RequestMethod.GET)

public List<Customer> getCustomerList() throws IOException{

    List<Customer> customers= customerDao.getCustomer();
    return customers;
}

1 个答案:

答案 0 :(得分:0)

使用“get”

时,您必须取消ajax缓存方法

$.ajax({
    url: 'xyz.com',
    cache: false,
    type: 'GET',
    data: yourData,
    success: successfunction,
    error: errorfunction 
});

或者您可以取消标记中的所有缓存操作;

<meta http-equiv="PRAGMA" content="NO-CACHE">

但有时候它不会真正有效:)

相关问题