Annotation Type MvcBinding


  • @Retention(RUNTIME)
    @Target({PARAMETER,METHOD,FIELD})
    @Documented
    public @interface MvcBinding
    This annotation is used to enable Jakarta MVC-specific binding rules for a Jakarta RESTful Web Services parameter binding. It can be placed on fields and method parameters together with Jakarta RESTful Web Services binding annotations such as FormParam, QueryParam, etc.

    MVC parameter binding differs from traditional Jakarta RESTful Web Services parameter binding in the following aspects:

    • In Jakarta RESTful Web Services binding and validation errors result in an exception being thrown which can only be handled by a corresponding exception mapper. This usually doesn't make sense for web applications, because errors must be processed by the controller, so they can be displayed on the resulting HTML page. In case of Jakarta MVC bindings such errors don't prevent the controller from being invoked and are instead made available via the injectable BindingResult class.
    • Jakarta RESTful Web Services parameter type conversion isn't locale-aware. The standard Jakarta RESTful Web Services converters always use a fixed locale to parse numbers and dates. In MVC applications users typically enter data into forms in their native locale. Therefore, Jakarta MVC bindings perform data type conversion by respecting the request locale resolved via LocaleResolver.
    Since:
    1.0
    Author:
    Christian Kaltepoth, Ivar Grimstad
    See Also:
    BindingResult, LocaleResolver