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

getFloatParameter

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

Get a Float parameter, or null if not present. Throws an exception if it the parameter value isn't a number.

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 Float value, or null if not present

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

Get a float parameter, with a fallback value. Never throws an exception. Can pass a distinguished value as 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