This file contains 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
<parent> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-parent</artifactId> | |
<version>2.1.1.RELEASE</version> | |
<relativePath/> | |
</parent> | |
<dependencies> | |
<dependency> | |
<groupId>org.springframework.boot</groupId> |
This file contains 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
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<configuration> | |
<source>9</source> | |
<target>9</target> | |
</configuration> | |
</plugin> |
This file contains 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 | |
@EnableWebFlux | |
public class WebConfig implements ApplicationContextAware, WebFluxConfigurer { | |
ApplicationContext context; | |
@Override | |
public void setApplicationContext(ApplicationContext context) { | |
this.context = context; | |
} |
This file contains 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
//... | |
@Bean | |
public ITemplateResolver thymeleafTemplateResolver() { | |
final SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver(); | |
resolver.setApplicationContext(this.context); | |
resolver.setPrefix("classpath:views/"); | |
resolver.setSuffix(".html"); | |
resolver.setTemplateMode(TemplateMode.HTML); | |
resolver.setCacheable(false); |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>I18N Spring Webflux</title> | |
</head> | |
<body> | |
<p>Hi there, you have successfully setup application with Spring Boot, Spring Webflux and Thymleaf</p> | |
</body> | |
</html> |
This file contains 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
@Component | |
public class WelcomeHandler { | |
public Mono<ServerResponse> hello(ServerRequest request) { | |
return ServerResponse | |
.ok() | |
.contentType(MediaType.TEXT_HTML) | |
.render("index"); | |
} | |
//... |
This file contains 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 | |
public class WelcomeRouter { | |
@Bean | |
public RouterFunction<ServerResponse> route(WelcomeHandler welcomeHandler) { | |
return RouterFunctions | |
.route(RequestPredicates.GET("/index") | |
.and(RequestPredicates.accept(MediaType.TEXT_HTML)), welcomeHandler::hello); | |
This file contains 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
@SpringBootApplication | |
public class I18NWebfluxApplication { | |
public static void main(String[] args) { | |
SpringApplication.run(I18NWebfluxApplication.class, args); | |
} | |
} |
This file contains 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
label.welcome = Welcome | |
label.content = This is sample project for Internalization and Localization in Webflux | |
label.changeLang = Supported languages | |
label.lang.en = English | |
label.lang.fr = French | |
label.lang.cn = Chinese | |
label.lang.de = German |
This file contains 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
@Bean | |
public MessageSource messageSource() { | |
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); | |
messageSource.setBasenames("languages/messages"); | |
messageSource.setDefaultEncoding("UTF-8"); | |
return messageSource; | |
} |
OlderNewer