2015-05-26 39 views
0

我使用angularjs和spring mvc来构建一个应用程序,我写了其余的api,它将从后端获取数据,并且使用angularjs ng-grid显示它。我的问题是,当我点击刷新按钮,我得到的答复为HTTP状态405 - 不支持请求方法'GET'我得到这个响应的原因是什么?以及如何解决这个问题?单页网页应用程序刷新按钮不支持

有什么办法,如果我点击浏览器的刷新按钮,它应该指向我的应用程序的着陆页。

角的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; 
} 
+0

你最好告诉我们你是如何调用REST API(您angularjs代码)和控制器的实现。我想你没有好好处理'@ RequestMapping'。 – Rebornix

+0

我已经添加了代码 – user3844950

回答

0

你不得不取消AJAX缓存方法同时使用 “获取”

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

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

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

但不会真正有效,而有些时候:)

+0

我在请求时禁用了缓存,但它不起作用,如果我点击刷新页面,而不是刷新它,它应该提示到其他页面。 – user3844950

+0

尝试使用POST方法获取相同的链接 –