title: Configure Spring Security to return JSON response after authentication
body: <p>I have a legacy application that is in spring 4 with UI as JSP. Need move the presentation layer from spring to react app. When I call /login with parameters it gives me an HTML, How do I change my existing spring security logic so that it returns a json response.</p>
  
  <p>Here is the code snippet </p>
  
  <pre><code>protected void configure(HttpSecurity http) throws Exception {      
          http.sessionManagement().maximumSessions(1).and().invalidSessionUrl(URLConstants.LOGIN_URL);
          http.csrf().disable();
          http.anonymous().disable()
                  .authorizeRequests().antMatchers("/")
                  .access("hasRole('USER') or hasRole('ADMIN') or hasRole('DC MANAGER')")
  .and().formLogin()          .loginProcessingUrl(URLConstants.LOGIN_URL).usernameParameter("ssoId").passwordParameter("password").and()
  .rememberMe().rememberMeParameter("remember-me").tokenRepository(tokenRepository)               .tokenValiditySeconds(18400).and().exceptionHandling().accessDeniedPage("/Access_Denied");
      }
  </code></pre>