フォーム enctype "multipart/form-data" によって送信されるリクエスト パラメータを取得しようとしています。私はapache commons fileuploadを使用しています。
私のコードは以下です。
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List items = upload.parseRequest(req);
Iterator uploadIterator = items.iterator();
while(uploadIterator.hasNext()){
FileItem uploadedItem = (FileItem) uploadIterator.next();
if (uploadedItem.isFormField()){
if (uploadedItem.getFieldName().equals("name")){
name = uploadedItem.getString();
}
}else{
//Uploaded files comes here
}
フォームの HTML コードは次のとおりです。
<form name="form" id="form" method="post" action="ServletIncluirEvento"
enctype="multipart/form-data">
... //Here comes a lot of inputs (I changed the name of the attribute because I am from Brazil and the names are in portuguese)
<select size="9" id="idOpcoesSelecionadas" name="opcoesSelecionadas" multiple style="width: 100%;">
<%
it = colecaoUsuarioSelecionado.iterator(); String name= "";
while (it.hasNext()) {
usuario = (Usuario) it.next();
name += usuario.getName() + "/"; %>
<option value="<%=usuario.getLogin()%>">
<%=usuario.getName()%>
</option>
<%
}
%></select>
<input type="hidden" value="<%=name%>" name="name" />
それでも、パラメーターは null になります。
誰かが解決方法を知っていますか?
前もって感謝します