Created
April 1, 2020 12:44
-
-
Save NeilAlishev/11642fd955e22f4bf435ea43b32e0ddb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
@ComponentScan("ru.alishev.springcourse") | |
@EnableWebMvc | |
public class SpringConfig implements WebMvcConfigurer { | |
private final ApplicationContext applicationContext; | |
@Autowired | |
public SpringConfig(ApplicationContext applicationContext) { | |
this.applicationContext = applicationContext; | |
} | |
@Bean | |
public SpringResourceTemplateResolver templateResolver() { | |
SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver(); | |
templateResolver.setApplicationContext(applicationContext); | |
templateResolver.setPrefix("/WEB-INF/views/"); | |
templateResolver.setSuffix(".html"); | |
return templateResolver; | |
} | |
@Bean | |
public SpringTemplateEngine templateEngine() { | |
SpringTemplateEngine templateEngine = new SpringTemplateEngine(); | |
templateEngine.setTemplateResolver(templateResolver()); | |
templateEngine.setEnableSpringELCompiler(true); | |
return templateEngine; | |
} | |
@Override | |
public void configureViewResolvers(ViewResolverRegistry registry) { | |
ThymeleafViewResolver resolver = new ThymeleafViewResolver(); | |
resolver.setTemplateEngine(templateEngine()); | |
registry.viewResolver(resolver); | |
} | |
} |
Почему на запрос: http://localhost:8080/hello-world Выдаёт: HTTP Status 500 – Внутренняя ошибка сервера ??? Всё делал по урокам. И на предыдущем уроке через xml настройки такая же ерунда была.
Версия Thymeleaf Sping5 не может работать с современной версией Spring6, поменяй версию Thymeleaf - spring с 5 на 6 и заработаеет
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
на сегодняшний день рабочие зависимости:
spring.version - 6.2.0
thymeleaf-spring6 - 3.1.2.RELEASE
jakarta.servlet - 6.0.0
А также tomcat 10.1.34, openjdk - 22