Annotation Interface WebController


@Retention(SOURCE) @Target(TYPE) public @interface WebController

The WebController annotation is used in conjunction with the @Bean annotation to indicate a web controller bean.

Web controller beans are used to specify web routes exposed in a module. These routes are aggregated in a generated WebRouterConfigurer bean that can be used to configure a web router.

Web routes are declared as methods annotated with @Webroute and implementing the exchange handler.

A web controller defines a base path, set to '/' by default, for all the routes defined in the controller.

For instance, in the following example a request to /book is handled by the getList() method and a request to /book/1 by the get() method.


 @WebController( path = "/book" )
 @Bean
 public class BookResource {

     @WebRoute
     public List<Book> getList() {
         ...
     }

     @WebRoute( path = "{id}" )
     public Book get() {
         ...
     }
 }
 
Since:
1.0
Author:
Jeremy Kuhn
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The base path of all the routes defined in the web controller.
  • Element Details

    • path

      String path

      The base path of all the routes defined in the web controller.

      Returns:
      the base path
      Default:
      "/"