This version is still in development and is not considered stable yet. For the latest stable version, please use Spring Framework 6.1.13!spring-doc.cn

This version is still in development and is not considered stable yet. For the latest stable version, please use Spring Framework 6.1.13!spring-doc.cn

Spring WebFlux provides an annotation-based programming model, where @Controller and @RestController components use annotations to express request mappings, request input, handle exceptions, and more. Annotated controllers have flexible method signatures and do not have to extend base classes nor implement specific interfaces.spring-doc.cn

The following listing shows a basic example:spring-doc.cn

@RestController
public class HelloController {

	@GetMapping("/hello")
	public String handle() {
		return "Hello WebFlux";
	}
}
@RestController
class HelloController {

	@GetMapping("/hello")
	fun handle() = "Hello WebFlux"
}

In the preceding example, the method returns a String to be written to the response body.spring-doc.cn