2014-11-25 75 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