【发布时间】:2014-12-13 20:49:13
【问题描述】:
谁能告诉我如何使用spring mvc portlet 控制器上传文件并将输入参数传递给控制器?
jsp中的动作URL和表单:
<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”参数为空。
控制器代码:
@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
文件上传部分工作正常,但我没有得到“selectedDetail”参数。请帮忙。
环境细节
- WebSphere Portal v7002
- IDE - RAD v8.5
- 春季版 3.1.0
如果您需要任何其他详细信息,请告诉我。
【问题讨论】:
标签: spring spring-mvc websphere-portal spring-portlet-mvc