Stack Exchange
Spring Boot + Security : unable to serve static page : Request method 'GET' not supported
Built a web app using spring boot 1.5.6 with spring security (security-core 4.2.3). Getting below error when accessing the app root. Ideally acc to documentation it should serve the index page on context root, but getting this error.
2018-10-31 18:58:31.879  WARN 5536 --- [nio-8080-exec-1] o.s.web.servlet.PageNotFound             : Request method 'GET' not supported
2018-10-31 18:58:31.880  WARN 5536 --- [nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved exception caused by Handler execution: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported
Security Config is below,
@Override
protected void configure(HttpSecurity http) throws Exception {
    http.csrf().disable();
    http.authorizeRequests().antMatchers("/token").permitAll();
    http.authorizeRequests().antMatchers("/").permitAll();
    http.authorizeRequests().antMatchers("/api/**").authenticated().and().exceptionHandling()
            .authenticationEntryPoint(entryPoint).and().authorizeRequests().antMatchers(HttpMethod.OPTIONS)
            .permitAll().and().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
            .addFilterAt(authenticationTokenFilter(), UsernamePasswordAuthenticationFilter.class);
}

@Override
public void configure(WebSecurity web) throws Exception {
    web.ignoring().antMatchers("app/token");
    web.ignoring().antMatchers("/");
}

pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.temp.am</groupId>
<artifactId>app</artifactId>
<version>1.0.0</version>
<!-- For deployment comment the JAR packaging, disable CORS at class -->
<packaging>war</packaging>
<!-- <packaging>jar</packaging> -->
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.6.RELEASE</version>
</parent>
<properties>
    <project.build.sourceEncoding>Cp1252</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>
    <tomcat.version>8.0.15</tomcat.version>
</properties>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <compilerVersion>1.8</compilerVersion>
                <fork>true</fork>
            </configuration>
        </plugin>

    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>11.2.0.3.0</version>
    </dependency>
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.6</version>
    </dependency>
    <dependency>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
    </dependency>

    <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

    <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt</artifactId>
        <version>0.6.0</version>
    </dependency>
</dependencies>


Properties spring.mvc.view.prefix=WEB-INF/
spring.mvc.view.suffix=.html
According to doc any static content in /public or /static or /resource should render as we hit application root in a browser. Also, I have noticed Authentication filter (custom filter extending AbstractAuthenticationProcessingFilter) is called twice by spring, first: VirtualFilterChain, second: ApplicationFilterChain. I not am sure why Authentication filter is placed in both FilterChains : originalFilter as well as additionalFilters. I have tried my best to go through stackoverflow answers and spring documentation: went through doc many times to see if I am missing any configuration.

Your spring security configuration is correct. It is not a problem related to spring-security because is neither a problem of authorization or authentication. Could you please paste the controller responding to GET "/" ? Another questions, you are trying to return a static html file (without data from controller)?

I do not have a controller for "/", by default spring boot has to show index page for "/" : context request. Yes my index page is static html page, which contains my angular app.

If your page is a static html page it should be available on http://localhost:8080/index.html. Could you try this? You said "spring boot has to show index page for "/"", how did you configure this mapping between / and index.html?

I will try this localhost:8080/index.html. I read in the documentation: we shall get index page by default on context. Reference :  spring-boot/docs/1.5.6.RELEASE

No @Adina "localhost:8080/index.html" is not working.
