I am currently working on a project which is separated into frontend (html5, jquery, css) and backend (Spring4 mvc with java config -no web.xml-, exposing rest for the view to consume it), each of which has its own pom that depends on the same parent pom.
When I compile the main project, 2 wars are generated (front and backend), which I later deploy in tomcat 7.
Backend is working fine (i've already tested it with psotman) and frontend works fine also if I open the html from outside tomcat (when I open index.html from a folder on my computer). However when I deploy the frontend war together with te backend war in tomcat and enter "localhost:8080/myAppsName/", http eror 404 is thrown. I understand that the html can't be found in order to render the index page.
Backend AppConfig.java:
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "org.fedelaper.spring")
public class AppConfig {
@Bean
public ViewResolver internalResourceViewResolver() {
InternalResourceViewResolver internalResourceViewResolver = new InternalResourceViewResolver();
internalResourceViewResolver.setPrefix("/frontend/");
internalResourceViewResolver.setSuffix(".html");
return internalResourceViewResolver;
}
}
Backend AppInitializer.java:
@SuppressWarnings("unchecked")
public class AppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@SuppressWarnings("rawtypes")
@Override
protected Class[] getRootConfigClasses() {
return new Class[] { AppConfig.class };
}
@SuppressWarnings("rawtypes")
@Override
protected Class[] getServletConfigClasses() {
return null;
}
@Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
}
I DO have a web.xml in project frontend which is actually empty:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
</web-app>
My question is: - How should I set index.html to be the default home page of my app when entering localhost:8080/myAppsName?