2016-11-04 63 views
1

我使用的春季啓動和春季安全的UI路由器庫。 當我嘗試訪問我定義的路由時,什麼也沒有發生,我甚至在控制檯中都沒有出現錯誤。AngularJs的ui路由器不工作在春季啓動

這裏是我的app.js文件

var app = angular.module("app", ['ui.router']); 

app.config(function($stateProvider, $urlRouterProvider) { 
// 
// For any unmatched url, redirect to /state1 
$urlRouterProvider.otherwise("/"); 
// 
// Now set up the states 
$stateProvider 
    .state('default', { 
     url: "/", 
     templateUrl: "partials/firstpage.html" 
    }) 

.state('register', { 
    url: "/register", 
    templateUrl: "partials/register.html" 
}) 

.state('login', { 
    url: "/login", 
    templateUrl: "partials/login.html" 
}) 

});

index.html文件:

<!DOCTYPE html> 
<html> 
<head> 
<meta charset="ISO-8859-1"> 

<script src="assets/js/jquery-2.1.4.js"></script> 

<script src="assets/bootstrap/js/bootstrap.js"></script> 
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"> </script> 
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.3.1/angular-ui-router.js"> </script> 

<script src="app.js"> </script> 
<script src="controllers/navbar.controller.js"> </script> 

</head> 

<body> 
<div ui-view> </div> 

</body> 

的WebSecurityConfiguration類:

protected void configure(HttpSecurity httpSecurity) throws Exception { 
    httpSecurity 
      .csrf() 
      .disable() 
      .exceptionHandling() 
      .authenticationEntryPoint(authenticationEntryPoint) 
      .and() 
      .sessionManagement() 
      .sessionCreationPolicy(SessionCreationPolicy.STATELESS) 
      .and() 
      .authorizeRequests() 
      .antMatchers(
        HttpMethod.GET, 
        "/", 
        "/*.html", 
        "/favicon.ico", 
        "/**/*.html", 
        "/**/*.css", 
        "/**/*.js", 
        "/**/**/*.css", 
        "/**/**/*.js", 
        "/**/**/*.html", 
        "/**/**/**/*.css", 
        "/**/**/**/*.js", 
        "/**/**/**/*.html", 
        "/**/**/**/**/*.css", 
        "/**/**/**/**/*.js"   
      ).permitAll() 
      .antMatchers("/auth/**", "/").permitAll() 
      .anyRequest().authenticated(); 

    // Custom JWT based authentication 
    httpSecurity 
      .addFilterBefore(authenticationTokenFilterBean(), UsernamePasswordAuthenticationFilter.class); 
} 

這裏是我的項目結構: project structure

有什麼,我應該添加到我的代碼來配置用於Spring啓動的ui路由器庫?

+0

Thailand

回答

0

您的HTML代碼沒有ng-app指令。所以基本上你的角度應用程序沒有變得初始化

+0

現在,它的工作,非常感謝你! –