2014-11-25 82 views
0

我啓動服務器後,當我單擊鏈接到這些頁面時,它工作正常。但是當我刷新頁面失敗時,似乎將路由URL發送到服務器並且找不到。後端是彈簧安置刷新時AngularJS路由失敗

app.config([ '$routeProvider', '$locationProvider', 
      function($routeProvider, $locationProvider) { 
       $locationProvider.html5Mode(true).hashPrefix('!'); 
       $routeProvider.when('/k3/test', { 
        controller : 'liantestCtrl', 
        templateUrl : '/views/lian.html' 
       })otherwise({ 
        redirectTo : '/k3/fu' 
       }); 
      } ]); 

錯誤:

HTTP ERROR 404 

Problem accessing /k3/test. Reason: 

    Not Found 
Powered by Jetty:// 

我需要任何其它設置

+1

你也必須配置@服務器,因爲你使用'html5mode'爲'true'。 [看看@ **服務器端**](https://docs.angularjs.org/guide/$location) – Jai 2014-11-25 09:02:35

回答

0

的原因可能是因爲你沒有URL到位重寫,因此服務器無法解析請求的URL。 您應該添加一個rewrite rule以將所有請求重定向到index.html,URL將由AngularJS管理。

+0

謝謝,讓我知道原因 – 2014-11-26 09:29:21