Class FormData

java.lang.Object
build.serve.form.FormData

public final class FormData extends Object
Parsed application/x-www-form-urlencoded form data.

Obtain an instance from an inbound Request:

var form = FormData.from(exchange.request());
var name = form.get("name").orElse("");
Since:
Apr-2026
Author:
reed.vonredwitz
  • Method Details

    • from

      public static FormData from(build.serve.foundation.Request request)
      Parses application/x-www-form-urlencoded form data from the given Request.
      Parameters:
      request - the inbound request
      Returns:
      the parsed FormData
    • parse

      public static FormData parse(String body)
      Parses application/x-www-form-urlencoded form data from a raw string.
      Parameters:
      body - the raw form body (e.g., "name=Alice&age=30")
      Returns:
      the parsed FormData
    • get

      public Optional<String> get(String name)
      Returns the first value for the given field name, or empty if absent.
      Parameters:
      name - the field name
      Returns:
      the first value, or empty
    • getAll

      public List<String> getAll(String name)
      Returns all values for the given field name.
      Parameters:
      name - the field name
      Returns:
      all values, or an empty list if absent
    • fields

      public Map<String, List<String>> fields()
      Returns all fields as an unmodifiable map.
      Returns:
      the field map