I am currently exploring a spring boot webflux project.
Successfully rendered static HTML using Thymeleaf.
Added a login page with CSS and JS, but encountered issues with rendering them in the HTML. The browser tools showed 404 errors for CSS and JS files. Below are the relevant codes:
--webConfig.java [src/main/java/com/author/projectname/configuration]--
@EnableWebFlux
@Configuration
public class WebConfig implements ApplicationContextAware, WebFluxConfigurer {
ApplicationContext context;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.context = context;
}
@Bean
public ITemplateResolver thymeleafTemplateResolver() {
// Resolver configuration
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
// Resource handler configuration for CSS and JS
}
@Bean
public SpringWebFluxTemplateEngine thymeleafTemplateEngine() {
// Template engine configuration
}
@Bean
public ThymeleafReactiveViewResolver thymeleafReactiveViewResolver() {
// View resolver configuration
}
@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
// View resolver registration
}
}
--login.html [src/main/resources/templates]--
<!DOCTYPE html>
<html xmlns="http://www.thymeleaf.org">
<!-- Login page HTML content -->
</html>
--login.css [src/main/resources/css]--
/* CSS styles for the login page */
body {
background-color: #181828;
}
/* Other CSS styles */
--login.js [src/main/resources/js]--
// JavaScript code for the login page
$('#nmberone').click(function() {
// Click event handling logic
});
// Other JavaScript functions
Despite trying different solutions found online, the issue related to Thymeleaf settings persists. What could be causing this problem?