Nanor Nanor - 1 year ago 110
Java Question

Spring on Wildfly not rendering index.html when root URL hit

Due to project requirements I have to deploy a Spring application to a server incapable of running Tomcat and only capable of running WildFly. When I had a very simple project running on Tomcat and the root URL was hit

it rendered my
. Since migrating to WildFly and refactoring the structure of my project,
no longer renders the
but I can still reach other URLs.

I've tried to implement a
file under
like this:


is the
but to no avail.

Consider my

package brass.ducks;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

public class ApplicationConfig extends SpringBootServletInitializer{

public static void main(String[] args) {, args);

protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(applicationClass);

private static Class<ApplicationConfig> applicationClass = ApplicationConfig.class;


class GreetingController {

String hello(@PathVariable String name) {
return "Hello, " + name + "!";

and consider my

package brass.ducks.application;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

public class Controller {

public String greeting() {
return "Hello, there.";

And finally should it be relevant, my folder structure:


returns "Hello, there" and
returns "Hello name". How can I fix this?

Answer Source

Depending on your exact configuration something along the lines of this should work:

public class LandingPageController {

public String showHomePage(Map<String, Object> model) {
    return "/WEB-INF/index.html";   

This is going to explicitly map / to index.html.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download