blob: 99ef0c9123d290c09f57e09fb70e949b7a28d3f0 [file] [log] [blame]
<!--
/***************************************************************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
***************************************************************************************************************************/
-->
RequestFormData
<p>
The {@link oajr.RequestFormData} object is the API for accessing the HTTP request body as form data.
It can be accessed by passing it as a parameter on your REST Java method:
</p>
<p class='bpcode w800'>
<ja>@RestMethod</ja>(...)
<jk>public</jk> Object myMethod(RequestFormData query) {...}
</p>
<h5 class='figure'>Example:</h5>
<p class='bpcode w800'>
<ja>@RestMethod</ja>(...)
<jk>public</jk> Object myMethod(RequestFormData formData) {
<jc>// Get query parameters converted to various types.</jc>
<jk>int</jk> p1 = formData.get(<js>"p1"</js>, 0, <jk>int</jk>.<jk>class</jk>);
String p2 = formData.get(<js>"p2"</js>, String.<jk>class</jk>);
UUID p3 = formData.get(<js>"p3"</js>, UUID.<jk>class</jk>);
}
</p>
<p>
Note that this object does NOT take GET parameters into account and only returns values found in the body of the request.
</p>
<p>
Some important methods on this class are:
</p>
<ul class='javatree'>
<li class='jc'><c>{@link oajr.RequestFormData} <jk>extends</jk> LinkedHashMap&lt;String,String[]&gt;</c>
<ul>
<li class='jm'>{@link oajr.RequestFormData#get(String,Class) get(String,Class)} - Get form-data parameter values converted to a POJO.
<li class='jm'>{@link oajr.RequestFormData#get(String,Type,Type...) get(String,Type,Type)} - Get form-data parameter value converted to a map or collection of POJOs.
<li class='jm'>{@link oajr.RequestFormData#getString(String,String) getString(String,String)} - Get form-data parameter value as a simple string.
<li class='jm'>{@link oajr.RequestFormData#getInt(String,int) getInt(String,int)} - Get form-data parameter value as an integer.
<li class='jm'>{@link oajr.RequestFormData#getBoolean(String,boolean) getBoolean(String,boolean)} - Get form-data parameter value as a boolean.
<li class='jm'>{@link oajr.RequestFormData#addDefault(String,Object) addDefault(String,Object)} - Programmatically set a default value for a form-data parameter.
</ul>
</ul>
<ul class='seealso'>
<li class='ja'>{@link oaj.http.annotation.FormData}
<li class='ja'>{@link oaj.http.annotation.HasFormData}
</ul>