Сервлет [dispatcherServlet] в контексте с путем [] выдал исключение [Путь кругового просмотра [логин]JAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Сервлет [dispatcherServlet] в контексте с путем [] выдал исключение [Путь кругового просмотра [логин]

Сообщение Anonymous »

Я новичок в Spring Boot, но пытаюсь скомпилировать и запустить старый Java-код Spring Boot, который выдает следующую ошибку:

Код: Выделить всё

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [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.)] with root cause
Мой файл login.jsp выглядит следующим образом:

Код: Выделить всё






Username


Password



Log in

и мой файл WebSecurityConfig.java выглядит следующим образом:

Код: Выделить всё

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
import org.springframework.security.crypto.password.NoOpPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;

@Configuration
@EnableWebSecurity
public class WebSecurityConfig {

private final PasswordEncoder passwordEncoder;

@Autowired
public WebSecurityConfig(PasswordEncoder passwordEncoder) {
this.passwordEncoder = passwordEncoder;
}

@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/login");
return http.build();
}

@Bean
public InMemoryUserDetailsManager userDetailsService(PasswordEncoder encoder) {
var usr1 = User.builder()
.username("user1ka")
.password(encoder.encode("y445uri125"))
.roles("USER")
.build();
var usr2 = User.builder()
.username("user2ka")
.password(encoder.encode("sa678sha769"))
.roles("USER")
.build();
return new InMemoryUserDetailsManager(usr1, usr2);
}
}
и мой loginController.java выглядит следующим образом:

Код: Выделить всё

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class LoginController {

@RequestMapping(
value = "/login",
method = {RequestMethod.GET, RequestMethod.POST})
public String login() {
return "login";
}

}
Буду признателен, если вы сообщите мне, что вызывает вышеуказанную ошибку и как ее устранить. Огромное спасибо за вашу помощь и поддержку.


Подробнее здесь: https://stackoverflow.com/questions/790 ... ircular-vi
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»