我想將以前的J2EE招聘應用程序從servlet轉換爲struts,我想知道在Action類中放置request.getParameterValues(「name」)是否可行。下面是一個示例代碼:struts中的request.getParameterValues
public class ConfirmEditApplicantAction extends Action{
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// TODO Auto-generated method stub
String forward = "success";
**String screenNames[] = request.getParameterValues("screenName");**
//some codes here....
return mapping.findForward(forward);
}
}
是來自這個樣本形式在JSP中:
<div id="screenInformation" class="tab_content">
<h4>Screenings:</h4>
<form action="EditScreeningServlet" method="post">
<input type = "hidden" name ="applicantNumber" value="${infoObj.applicantNumber}" >
<table>
<c:forEach var="screen" items="${screenList}">
<input type = "hidden" name ="screenId" value="${screen.screenId}" >
<tr>
<td>Screen Type:  </td> <td><input type="text" value="${screen.screenName}" name="screenName" readonly ="true"></td>
</tr>
<tr>
<td>Date: </td> <td><input type="text" value="${screen.screenDate}" name="screenDate" class="date"></td>
</tr>
<tr>
<td>Result: </td>
<td>
<select name = screenResult>
<option value="Pass" ${screen.screenResult == 'Pass' ? 'selected' : ''}>Pass</option>
<option value="Fail" ${screen.screenResult == 'Fail' ? 'selected' : ''}>Fail</option>
<option value="" ${screen.screenResult == '' ? 'selected' : ''}></option>
</select>
</td>
</tr>
<tr><td> </td><td>  </td></tr>
</c:forEach>
</table>
<input type="submit" class="saveButton" value="SAVE">
</form>
請原諒我的模糊問題,但我的意思是,如果它沒有違反任何編碼規則或標準時,我將servlet代碼轉換爲struts。因爲我知道在將jsp的值傳遞給Action類時使用了ActionForm類。 – 2011-06-11 12:53:03
@mr。你好,我明白了。那麼,在那種情況下,我仍然會說,如果它有效,你可以這樣做。如果你有時間和精力,那麼通過一切手段使它更像Struts一樣的ActionForms。但是,如果這與工作有關,那麼可能會有時間和預算約束。 – deltaforce2 2011-06-11 13:23:13