Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-16598

Support Kotlin parameter default values in HTTP handler methods

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 5.0.4
    • Fix Version/s: 5.x Backlog
    • Component/s: Web
    • Labels:

      Description

      Support specifying defaults for e.g. @RequestMapping via Kotlin parameter default values like so:

      @GetMapping
      fun get(@RequestParam limit: Int = 20)
      

      Such a method should behave equivalent to @RequestMapping with defaultValue, except that the value does not need to be processed by converters, etc.

      This can be implemented in org.springframework.web.method.support.InvocableHandlerMethod using Kotlin Reflection (KCallable#callBy), which allows omitting parameters with default values.

        Attachments

          Activity

            People

            Assignee:
            sdeleuze S├ębastien Deleuze
            Reporter:
            diesieben07 Take Weiland
            Last updater:
            Spring Issues Spring Issues
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Days since last comment:
              3 years, 19 weeks, 4 days ago