Ho letto la seguente documentazione da spring.io e ha detto By default Spring Boot will serve static content from a directory called /static (or /public or /resources or /META-INF/resources) in the classpath
tuttavia quando ho inserito il mio file index.html sotto /resources
la stringa index
è appena stata renderizzata. Attualmente index.html
è in webapp e sto usando AngularJS.L'avvio di primavera non trova index.html nella cartella webapp
MvcConfiguration
@Configuration
public class MvcConfig {
@Bean
InternalResourceViewResolver viewResolver(){
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/webapp/");
resolver.setSuffix(".html");
return resolver;
}
}
Servizio riposante per pagina indice
@RestController
public class IndexController {
@RequestMapping("/")
public String index(){
System.out.println("Looking in the index controller.........");
return "index";
}
}
sulla mia console IDE Vedo Looking in the index controller......
stampato dal IndexController e sotto rete gli strumenti di sviluppo Chrome Ho solo vedi localhost 200
.
index.html
<body>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div ng-view></div>
<div>Angular seed app: v<span app-version></span></div>
Quindi cosa vuoi fare esattamente qui? hai inizializzato la tua app nella pagina indice ('ng-app')? –
Prova questo 'resolver.setPrefix ("/");' poiché 'src/main/webapp' è già nel classpath. –
@SanjayRawat, non ha funzionato ... – Drew1208