Spring Security doesn't post to provided login processing url
<p>For some weird reason, I cannot hit the controller that is registered to handle login posts. I just get redirected to this silly image that is in my resources folder:</p>

<pre><code>https://localhost:8443/images/piggy-bank.jpeg
</code></pre>

<p>Here is my controller. </p>

<pre><code>@RequestMapping(value = "/login/process", method = RequestMethod.POST)
public String loginPost(HttpSession session, Authentication authentication) {

    String client_id = (String) session.getAttribute("client_id");

    if (client_id.equals(Constants.TRUSTED_CLIENT)) {

        //TODO:
        /*
         * 1. Generate an access_token
         * 2. Save to database
         * 3. Form redirect url with all necessary tokens
         * 4. Return redirect url string
         */

        return "redirect:" + Constants.REDIRECT_TRUSTED_CLIENT; 

    }

    long userId = AuthenticationUtils.getAuthenticatedUserId(authentication);
    return "/user/" + userId;
}
</code></pre>

<p>Here is my security configuration:</p>

<pre><code>@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

    @Autowired
    @Qualifier("customUserDetailsService")
    UserDetailsService userDetailsService;

    @Autowired
    public void configureGlobalSecurity(AuthenticationManagerBuilder auth) throws Exception {
        auth.userDetailsService(userDetailsService);
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.
                authorizeRequests()
                .antMatchers("/","/sign_up","/resources/**").permitAll()
                .anyRequest().authenticated()
                .and()
            .formLogin()
                .permitAll()
                .loginPage("/login")
                .loginProcessingUrl("/login/process")
                .defaultSuccessUrl("/")
                .failureUrl("/access_denied")
                .and()
            .csrf()
                .and()
            .exceptionHandling()
                .accessDeniedPage("/access_denied")
                .and()
            .logout()
                .permitAll();

    }
}
</code></pre>

<p>And here's the view:</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html xmlns:th="http://www.thymeleaf.org"&gt;
    &lt;head lang="en"&gt;

        &lt;title&gt;Spring App&lt;/title&gt;

        &lt;!--/*/ &lt;th:block th:include="fragments/headerinc :: head"&gt;&lt;/th:block&gt; /*/--&gt;
    &lt;/head&gt;

    &lt;body&gt;
        &lt;div class="container"&gt;
            &lt;!--/*/ &lt;th:block th:include="fragments/header :: header"&gt;&lt;/th:block&gt; /*/--&gt;

            &lt;div id="mainWrapper"&gt;
                &lt;div class="login-container"&gt;
                    &lt;div class="login-card"&gt;
                        &lt;div class="login-form"&gt;
                            &lt;form th:action="@{/login/process}" method="post" class="form-horizontal"&gt;
                                &lt;div th:if="${param.error != null}"&gt;
                                    &lt;div class="alert alert-danger"&gt;
                                        &lt;p&gt;Invalid username and password.&lt;/p&gt;
                                    &lt;/div&gt;
                                &lt;/div&gt;
                                &lt;div th:if="${param.logout != null}"&gt;
                                    &lt;div class="alert alert-success"&gt;
                                        &lt;p&gt;You have been logged out successfully.&lt;/p&gt;
                                    &lt;/div&gt;
                                &lt;/div&gt;
                                &lt;div class="input-group input-sm"&gt;
                                    &lt;label class="input-group-addon" for="username"&gt;&lt;i class="fa fa-user"&gt;&lt;/i&gt;&lt;/label&gt;
                                    &lt;input type="text" class="form-control" id="username" name="username" placeholder="Enter Username" /&gt;
                                &lt;/div&gt;
                                &lt;div class="input-group input-sm"&gt;
                                    &lt;label class="input-group-addon" for="password"&gt;&lt;i class="fa fa-lock"&gt;&lt;/i&gt;&lt;/label&gt;
                                    &lt;input type="password" class="form-control" id="password" name="password" placeholder="Enter Password" /&gt;
                                &lt;/div&gt;
                                &lt;input type="hidden" name="${_csrf.parameterName}"   value="${_csrf.token}" /&gt;

                                &lt;div class="form-actions"&gt;
                                    &lt;input type="submit"
                                           class="btn btn-block btn-primary btn-default" value="Log in"/&gt;
                                &lt;/div&gt;
                            &lt;/form&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Inspecting my network data, I see that the form post to /login/process was successful and the server responded fine!</p>

<pre><code>Request URL:https://localhost:8443/login/process
Request Method:POST
Status Code:302 Found
Remote Address:[::1]:8443
</code></pre>

<p>The log during spring startup also affirms the registration of url "/login/post" to the aforementioned controller. Corresponding log:</p>

<pre><code>2016-04-21 20:44:30.725  INFO 25290 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/login/process],methods=[POST]}" onto public java.lang.String com.springapp.controllers.UserController.loginPost(javax.servlet.http.HttpSession,org.springframework.security.core.Authentication)
</code></pre>

<p>The situation may be something more insidious, because I can't seem to be redirected to even the defaultSuccessURL page, i.e. the index ("/"). The same is the case (i.e. loginProcessingURL and defaultSuccessfulURL not redirecting) exists even if I use the default out-of-box login view. Is there something wrong with my jsp view? Am I missing some security configuration?</p>

<p>However, manually entering /user/{id} OR any other url successfully lands me to the target url as long as I'm properly authenticated. What does that mean?</p>

<p>Finally here is the 'header.html' and 'headerinc.html' thymeleaf fragments which are inserted in  all my jsp:</p>

<p>header.html</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html xmlns:th="http://www.thymeleaf.org"&gt;
&lt;head lang="en"&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/&gt;

    &lt;script src="https://code.jquery.com/jquery-2.1.4.min.js"&gt;&lt;/script&gt;

    &lt;link href="../../static/css/app.css"
          th:href="@{css/app.css}" rel="stylesheet" media="screen"/&gt;
    &lt;link href="../../static/css/bootstrap.css"
          th:href="@{css/bootstrap.css}" rel="stylesheet" media="screen"/&gt;
    &lt;link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.2.0/css/font-awesome.css"
          th:href="@{/webjars/font-awesome/4.2.0/font-awesome.css}" rel="stylesheet" media="screen"/&gt;

&lt;/head&gt;
&lt;body&gt;

&lt;div class="container"&gt;
    &lt;div th:fragment="header"&gt;
        &lt;nav class="navbar navbar-default"&gt;
            &lt;div class="container-fluid"&gt;
                &lt;div class="navbar-header"&gt;
                    &lt;a class="navbar-brand" href="#" th:href="@{/}"&gt;Home&lt;/a&gt;
                    &lt;ul class="nav navbar-nav"&gt;
                        &lt;!-- if logged in, then display -logout, else display -login, -Sign up. --&gt;
                        &lt;div th:with="currentUser=${#httpServletRequest.userPrincipal?.name}"&gt;

                            &lt;div th:if="${currentUser != null}"&gt;
                                &lt;form th:action="@{/logout}" method="post"&gt;
                                    &lt;input type="submit" value="Log out"/&gt;
                                &lt;/form&gt;
                            &lt;/div&gt;

                            &lt;div th:if="${currentUser == null}"&gt;
                                &lt;li&gt;&lt;a href="#" th:href="@{/login}"&gt;Log in&lt;/a&gt;&lt;/li&gt;
                                &lt;li&gt;&lt;a href="#" th:href="@{/sign_up}"&gt;Sign up&lt;/a&gt;&lt;/li&gt;
                            &lt;/div&gt;

                            &lt;!-- This is to simply test some authentication logic--&gt;
                            &lt;a href="#" th:href="@{/users}"&gt;All Users&lt;/a&gt;
                        &lt;/div&gt;
                    &lt;/ul&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        &lt;/nav&gt;

        &lt;div class="jumbotron"&gt;
            &lt;div class="row text-center"&gt;
                &lt;div class=""&gt;
                    &lt;h2&gt;Spring Framework Example..&lt;/h2&gt;

                    &lt;h3&gt;Spring Boot Web App&lt;/h3&gt;
                &lt;/div&gt;
            &lt;/div&gt;
            &lt;div class="row text-center"&gt;
                &lt;img src="../../static/images/NewBannerBOOTS_2.png" width="400"
                     th:src="@{/images/piggy-bank.jpeg}"/&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>headerinc.html</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html xmlns:th="http://www.thymeleaf.org"&gt;
&lt;head lang="en" th:fragment="head"&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/&gt;
    &lt;link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" media="screen" /&gt;

    &lt;script src="https://code.jquery.com/jquery-2.1.4.min.js"&gt;&lt;/script&gt;
    &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"&gt;&lt;/script&gt;
    &lt;link href="../static/css/guru.css"
          th:href="@{/css/guru.css}" rel="stylesheet" media="screen"/&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>