上传文件并将参数发送到SpringPortlet控制器
你们中的任何一个人能告诉我如何使用SpringMVCPortletController上传文件并将输入参数传递给控制器吗 jsp中的操作URL和表单:上传文件并将参数发送到SpringPortlet控制器,spring,spring-mvc,websphere-portal,spring-portlet-mvc,Spring,Spring Mvc,Websphere Portal,Spring Portlet Mvc,你们中的任何一个人能告诉我如何使用SpringMVCPortletController上传文件并将输入参数传递给控制器吗 jsp中的操作URL和表单: <portlet:actionURL var="addDetailsURL"> <portlet:param name="addDetails" value="addDetailsValue"/> </portlet:actionURL> <div id = "<portlet:na
<portlet:actionURL var="addDetailsURL">
<portlet:param name="addDetails" value="addDetailsValue"/>
</portlet:actionURL>
<div id = "<portlet:namespace/>addDetailsDIV" >
<form action="${addDetailsURL}" enctype="multipart/form-data" method="post">
<input style="display:block;" type="text" name="selectedDetail" id='selectedDetail'/> <%-- holds the parameter that is supposed to be passed to the controller --%>
<table width = 100% cellspacing="5" cellpadding="5">
<tr>
<td colspan='2'><fmt:message key = "selectFileUploadTxt"/></td>
</tr>
<tr>
<td colspan='2'><input id="uploadedFile" type="file" name="uploadedFile" /></td>
</tr>
<tr>
<td >
<span id="<portlet:namespace />closeAddDetailDia">cancel</span>
</td>
<td align="left">
<Button id="uploadButton"><fmt:message key="addDetailButtonTxt" /></Button>
</td>
</tr>
</table>
</form>
</div>
文件上传部分工作正常,但我没有得到“selectedDetail”参数。请帮忙
环境详情
如果您需要任何其他详细信息,请告诉我。在后端,定义一个bean来保存表单数据,包括文件 我称之为FormBean。FormBean应该有一个类型为
私有org.springframework.web.multipart.commons.commons多部分文件 表单中的更改将包括在表单元素中包含“commandName”和“path”: &
下面的链接很好地解释了这一点: https:
@RequestMapping("VIEW")
public class AddDetailsController {
/**
*
* @param actionRequest
* @param actionResponse
* @return
* @throws IOException
*/
@SuppressWarnings({ "rawtypes", "unused" })
@ActionMapping(params = "addDetails=addDetailsValue")
public String fileUpload(ActionRequest actionRequest, ActionResponse actionResponse,
@RequestParam String selectedDetail
) throws PortletException, IOException {
System.out.println("selectedDetail : " + selectedDetail); // it is null
System.out.println("selectedDetail : " + actionRequest.getParameter("selectedDetail")); // it is null