boycod3 boycod3 - 4 months ago 23
AngularJS Question

angular route template not found 404

Hi when i run the spring angular app it is showing

GET http://localhost:8080/cyclone/admin/admin/cycle 404 (Not Found)
. i don't have any idea where the second admin came from on the url.

access url
<a href="#/cycle">Cycle</a>
and the html page under
WEB-INF/views/admin/cycle.html


Angular root setup

App.config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/cycle', {
templateUrl: 'admin/cycle.html',
controller: 'CycleController'
});
}]);


My Spring controller

@Controller
@RequestMapping(value = "/admin")
public class AdminController {
@RequestMapping("/cycle.html")
public String getCarPartialPage() {
return "admin/cycle";
}
}

Answer

Change the code like below

 $routeProvider.when('/cycle', {
   templateUrl: 'cycle.html',
   controller: 'CycleController'

});

and in spring controller

@RequestMapping(value = "/cycle.html", method = RequestMethod.GET)
public String getCarPartialPage() {
return "admin/cycle";
}
Comments