I keep getting a blank page when I render this application in tomcat 8. The only error I see is:
o.s.boot.context.web.ErrorPageFilter: Cannot forward to error page for
request [/] as the response has already been committed.
Therefore my issue is I am unable to render the index.html page.
I took a static page and added a spring-boot module in it. Ever since I made the change I have not been able to render the page again. I have the index.html file under templates
I added comments in my controller to see if they are even being hit and they are not:
@Controller
public class ApplicationController {
@Autowired
ContactService contactService;
@RequestMapping(value="/", method= RequestMethod.GET)
public String contactForm() throws IOException {
System.out.println("Inside GET in Application Controller");
//model.addAttribute("contact", new Contact());
return "index";
}
@RequestMapping(value="/contact", method= RequestMethod.POST)
public String contactSubmit() throws IOException {
System.out.println("Inside POST in Application Controller");
return "index";
}
}
I was using Thymeleaf but decided against it which is why the parameters in the methods are blank.
I have uploaded the project to GIT to make it easier for someone to poke around and download if so desired.
----------------Update 1----------------------
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
private static final Logger LOGGER = Logger.getLogger(WebConfig.class);
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("index");
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
registry.addResourceHandler("/css/**").addResourceLocations("/resources/css/");
registry.addResourceHandler("/images/**").addResourceLocations("/resources/images/");
registry.addResourceHandler("/image/**").addResourceLocations("/resources/image/");
registry.addResourceHandler("/javascripts/**").addResourceLocations("/resources/javascripts/");
}
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
}
There is really nothing else to show that I can think of. You can look at it on GIT for the other files if you so choose too.