本文整理汇总了Java中com.sun.jersey.multipart.FormDataBodyPart.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java FormDataBodyPart.getValue方法的具体用法?Java FormDataBodyPart.getValue怎么用?Java FormDataBodyPart.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jersey.multipart.FormDataBodyPart
的用法示例。
在下文中一共展示了FormDataBodyPart.getValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setFormParams
import com.sun.jersey.multipart.FormDataBodyPart; //导入方法依赖的package包/类
private static void setFormParams(FormDataMultiPart formData, Run run, String... excluded) throws IOException {
Collection<String> ex = new HashSet<String>(Arrays.asList(excluded));
Map<String,List<FormDataBodyPart>> formFields = formData.getFields();
for (Map.Entry<String,List<FormDataBodyPart>> e : formFields.entrySet()) {
String name = e.getKey();
if (ex.contains(name)) {
continue;
}
List<FormDataBodyPart> fields = e.getValue();
if (fields.isEmpty()) {
continue;
}
FormDataBodyPart field = fields.get(fields.size() - 1);
if (name.startsWith(ParamValue.METHOD_UPLOAD + "-")) {
name = name.substring(7);
ContentDisposition cd = field.getContentDisposition();
run.addUploadParamValue(name, cd.getFileName(), field.getValueAs(InputStream.class));
}
else {
String value = field.getValue();
setParam(run, name, value);
}
}
}
示例2: getString
import com.sun.jersey.multipart.FormDataBodyPart; //导入方法依赖的package包/类
private static String getString(FormDataMultiPart formData, String fieldName) {
FormDataBodyPart bodyPart = getBodyPart(formData, fieldName);
String value = bodyPart.getValue();
if (StringUtils.isEmpty(value)) {
Response response = Response.status(Response.Status.BAD_REQUEST).entity("Missing form value: " + fieldName).build();
throw new WebApplicationException(response);
}
return value;
}