I am a newbie to spring boot architecture. It says that to let the index pages to find static resources like js, we need to keep it under "src/main/resources/static".
Directory Structure:
Html files: src/main/webapp/WEB-INF/jsp/
js files: src/main/resources/static/js/
This is my index page:
<html ng-app="RollbackApp">
<head>
<title>My Rollback View</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.5/angular.js"></script>
<script type="text/javascript" src = "js/app.js"></script>
</head>
<body>
<div ng-controller="rollbackController"><p>
<button ng-click="rollback()">RollBack</button>
</p></div>
</body>
</html>
Currently the index page is not able to load my "app.js"
My Mvc config class is as follows:
package com.manoj;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
/**
* Created by manojma on 10/13/2017.
*/
@Configuration
@EnableWebMvc
public class ApplicationWebMvcConfig extends WebMvcConfigurerAdapter {
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/static/");
}
@Bean
public InternalResourceViewResolver viewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/WEB-INF/jsp/");
resolver.setSuffix(".html");
return resolver;
}
}
I am unable to find the reason, why it is not able to find my js files.
Please help me with this.!!