Valerii Sloboda Valerii Sloboda - 1 month ago 13x
AngularJS Question

Spring Boot and AngularJS

I want make some spring boot app. I've already created spring boot project, but I have a problem. My controller look like:

public class IndexController {

@RequestMapping(value="/home",method = RequestMethod.GET)
public String homepage(){
return "index";

But all what i see is not index.html, but only a word "index".
Therefore I want use angular.

angular.module('mvcApp', [])
.constant('MODULE_NAME', "index")
.config(['$routeSegmentProvider', '$routeProvider', function ($routeSegmentProvider, $routeProvider) {
.when('/', 'index')
.when('/index', 'index')
.when('/configuration', 'configuration')

$routeSegmentProvider.segment('index', {
templateUrl: 'HTML/index.html',
controller: 'IndexCtrl'

$routeProvider.otherwise({redirectTo: '/'});

and controller:

angular.module('mvcApp').controller('IndexCtrl', ['$scope', '$rootScope', function ($scope, $rootScope) {

$scope.hello = "Hello from AngularJS";


my index.html

<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<body ng-app="mvcApp" ng-controller="IndexCtrl">

Greeting page.


But it doesn't work, I see only error on my localhost.

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Sun Sep 04 15:33:41 CEST 2016
There was an unexpected error (type=Not Found, status=404).
No message available

How I can make this angular controller works and return properly views?


There should be class like that:

public class ConfigurationMVC extends WebMvcConfigurerAdapter {
    public ViewResolver getViewResolver() {
        InternalResourceViewResolver resolver = new InternalResourceViewResolver();
        return resolver;

    public void configureDefaultServletHandling(
            DefaultServletHandlerConfigurer configurer) {