spring-framework / org.springframework.web.bind / ServletRequestUtils / getStringParameter

getStringParameter

@Nullable open static fun getStringParameter(request: ServletRequest, name: String): String

Get a String parameter, or null if not present.

Parameters

request - current HTTP request

name - the name of the parameter

Exceptions

ServletRequestBindingException - a subclass of ServletException, so it doesn't need to be caught

Return
the String value, or null if not present

open static fun getStringParameter(request: ServletRequest, name: String, defaultVal: String): String

Get a String parameter, with a fallback value. Never throws an exception. Can pass a distinguished value to default to enable checks of whether it was supplied.

Parameters

request - current HTTP request

name - the name of the parameter

defaultVal - the default value to use as fallback