【发布时间】:2015-08-18 08:12:13
【问题描述】:
我必须将一个文件从我的 jsp 传递到我的 portlet 操作类 (java)。 我在我的 jsp 中创建了这一行。
<input type="file" name="file"/>
但是当我需要将它传递到我的 portlet 时,我不知道如何处理它。我应该使用 ParamUtil.getXXX() 方法来处理它,但我看不到任何保存文件数据的东西类型..它应该看起来像这样
String tin = ParamUtil.getString(actionRequest, "tin");
String surName = ParamUtil.getString(actionRequest, "surName");
String middleName = ParamUtil.getString(actionRequest, "middleName");
String givenName = ParamUtil.getString(actionRequest, "givenName");
String nameExt = ParamUtil.getString(actionRequest, "nameExt");
File file = ParamUtil. **<----- this is where I'm stuck :(**
Date birthDate = ParamUtil.getDate(actionRequest, "birthdate", DateFormat.getInstance());
String birthPlace = ParamUtil.getString(actionRequest, "birthplace");
String citizenship = ParamUtil.getString(actionRequest, "citizenship");
String civilStatus = ParamUtil.getString(actionRequest, "civilstatus");
String fatherFName = ParamUtil.getString(actionRequest, "fgivenName");
String fatherMName = ParamUtil.getString(actionRequest, "fmiddleName");
String fatherLName = ParamUtil.getString(actionRequest, "fsurName");
String motherFName = ParamUtil.getString(actionRequest, "mgivenName");
String motherMName = ParamUtil.getString(actionRequest, "mmiddleName");
String motherLName = ParamUtil.getString(actionRequest, "msurName");
String spouseFName = ParamUtil.getString(actionRequest, "sgivenName");
String spouseMName = ParamUtil.getString(actionRequest, "smiddleName");
String spouseLName = ParamUtil.getString(actionRequest, "ssurName");
String children[] = ParamUtil.getParameterValues(actionRequest, "children[]");
long pi_id = CounterLocalServiceUtil.increment();
personal_info pi = null;
pi = new personal_infoImpl();
pi = personal_infoLocalServiceUtil.createpersonal_info((int) pi_id);
pi.setTin(tin);
pi.setLname(surName);
pi.setFname(givenName);
pi.setMname(middleName);
pi.setName_ext(nameExt);
pi.setBirthDate(birthDate);
pi.setBirthplace(birthPlace);
pi.setPhoto(file); <------------ it's supposed to be saved in here.. but I'm stuck...
因此,我什至没有测试代码块..
【问题讨论】:
-
使用 UploadPortletRequest 获取文件
标签: java jsp model-view-controller liferay portlet