title: javax.servlet.ServletException: Circular view path [login]
body: <p>I am new to Spring Boot and want to add the Spring Security module to my previous project. I followed this <a href="https://spring.io/guides/gs/securing-web/" rel="nofollow noreferrer">link</a>. My Spring Boot version is <code>1.5.6.RELEASE</code>.</p>
  
  <p>Here is the security configuration</p>
  
  <pre><code>@Configuration
  @EnableWebSecurity
  public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http
              .authorizeRequests()
                  .antMatchers("/", "/home").permitAll()
                  .anyRequest().authenticated()
                  .and()
              .formLogin()
                  .loginPage("/login")
                  .permitAll()
                  .and()
              .logout()
                  .permitAll();
      }
  
      @Autowired
      public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
          auth
              .inMemoryAuthentication()
              .withUser("user").password("password").roles("USER");
      }
  }
  </code></pre>
  
  <p>Here is the MVC configuration:</p>
  
  <pre><code>@Configuration
  public class MvcConfig extends WebMvcConfigurerAdapter {
  
      @Override
      public void addViewControllers(ViewControllerRegistry registry) {
          registry.addViewController("/home").setViewName("home");
          registry.addViewController("/").setViewName("home");
          registry.addViewController("/hello").setViewName("hello");
          registry.addViewController("/login").setViewName("login");
      }
  </code></pre>
  
  <p>I can ensure that <code>home.html</code>, <code>hello.html</code> and <code>login.html</code> are located in <code>resources/templates/</code>. As I added the Spring Security part to a previous project, I also has an controller that handles jpa request</p>
  
  <pre><code>@Controller
  @RequestMapping("/test/pgsql")
  public class TestPostgreSQLController {
  
      @Autowired
      private CustomerRepository customerRepository;
  
      @RequestMapping("/save")
      public @ResponseBody
      String process() {
          customerRepository.save(new Customer("Neo", "Chan"));
          customerRepository.save(new Customer("Luke", "Liu"));
          customerRepository.save(new Customer("Ran", "Guo"));
          customerRepository.save(new Customer("Joey", "Chen"));
          customerRepository.save(new Customer("Larry", "Huang"));
          return "Done";
      }
  
      @RequestMapping("/findbyid")
      public @ResponseBody String findById(@RequestParam("id") long id) {
          String result = "";
          result = customerRepository.findOne(id).toString();
          return result;
      }
  
      @RequestMapping("/find")
      public @ResponseBody String find(@RequestParam("lastname") String lastName) {
          String results = "";
          for (Customer bauer : customerRepository.findCustomersByLastName(lastName)) {
              System.out.println(bauer.toString());
              results = results + bauer.toString() + "&lt;br&gt;";
          }
          return results;
      }
  
  
  }
  </code></pre>
  
  <p>the pom.xml is like this</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.postgresql&lt;/groupId&gt;
          &lt;artifactId&gt;postgresql&lt;/artifactId&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>I build the project as jar package. When I visit the <code>localhost:8080/home</code> or <code>localhost:8080/login</code> address. It throws the following exception:</p>
  
  <pre><code>javax.servlet.ServletException: Circular view path [login]: would dispatch back to the current handler URL [/login] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
  </code></pre>
  
  <p>Any suggestion? Thanks in advance.</p>