[英]How to get jsp text field data into java file?
您好,我試圖獲取其他Java文件中文本字段的值。 我正在嘗試以下代碼。
<aui:form action="<%=editpollURL.toString() %>" enctype="multipart/form-data"
method="post" >
<aui:input name="title" label="title"/>
<aui:input type="textarea" name="pollquestion" rows="5" cols="25" label="Poll
Question" />
以下是我的Java代碼。
String title = ParamUtil.getString(actionRequest, "title");
String pollquestion = ParamUtil.getString(actionRequest, "pollquestion");
System.out.println("Your inputs ==> " + title + ", " + pollquestion);
我無法從jsp文件寫入用戶輸入。請幫助我。
對於您的情況,您應該像這樣使用UploadPortletRequest:
public void yourAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException {
UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(request);
String filePath = uploadRequest.getFileName("filePath");
try{
java.io.File file = uploadRequest.getFile("filePath");
//Manage the Upload
}catch (Exception e) {
///
}
}
您的jsp輸入可能像這樣:
<aui:input type="file" label="upload your file" name="filePath" />
確保使用匹配的“名稱”屬性,並使用“ type =“ file””
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.