Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Creating a reactive web controller

Pragya Keshap answered on February 15, 2023 Popularity 3/10 Helpfulness 1/10

Contents


More Related Answers

  • make controller resource
  • Creating a Spring MVC web controller
  • @Controller
  • Writing Reactive Web Controllers

  • Creating a reactive web controller

    0

    @Controller: Spring Web’s annotation to indicate this class contains web methods that render templates.

    @GetMapping: Spring Web’s annotation to map GET / web calls onto this method.

    Mono: Mono is Reactor’s single-valued reactive type. Rendering is Spring WebFlux’s value type that allows us to pass both the name of the view to render along with model attributes.

    Flux.fromIterable(): This static helper method lets us wrap any Java Iterable and then use our reactive APIs.

    DATABASE.values(): This is a temporary data source until we get to Chapter 10, Working with Data Reactively.

    collectList(): This Flux method lets us gather a stream of items into

    Mono>.

    map(): This operation lets us access the list inside that Mono where we then transform it into a Rendering. The name of the view we wish to render is "index". We also load up the model "employees" attribute with the values found inside this Mono.

    build(): Rendering is a builder construct, so this is the step that transforms all the pieces into a final, immutable instance. It’s important to understand that when inside the map() operation, the output is a Mono.

    Popularity 3/10 Helpfulness 1/10 Language java
    Source: Grepper
    Tags: java reactive
    Link to this answer
    Share Copy Link
    Contributed on Feb 15 2023
    Pragya Keshap
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.