2014-06-19 3 views
0

저는 초보 개발자이며 Java 웹 사이트에서 웹 응용 프로그램을 만들고 있습니다. 사용자가 정보를 입력 한 후 비어있는 내 스트럿 양식에 문제가 있습니다. 나는 그것을 해결하기 위해 여러 방법을 시도했지만 아무 것도 효과가 없었다. 어쩌면 코드 라인이 도움이 될지도 모른다;). 내 JSP 페이지 :Struts 양식이 아직 비어 있습니다.

<tr> 
<td colspan="5"> 
    <div class="content" align="center"> 
     <form action="statistiques.do" method="POST"> 
      <input type="hidden" name="operation" value="module1"> 
      <tr> 
       <td><font size="3">&Eacute;tat&nbsp;:&nbsp;</td> 
       <td> 
        <select name="choixEtat"> 
         <option value='1' selected>Tous</option> 
         <option value='2' >Actif</option> 
         <option value='3' >Inactif</option> 
        </select> 
       </td> 
      </tr> 
      <tr> 
       <td>Date de d&eacute;but&nbsp;:<span style="font-weight: bolder; color: red;">&nbsp;&#42;</span></td> 
       <td> 
        <input type="text" name="dateDebut" size="10" maxlength="10" id="date" value="" 
          required="required"> 
       </td> 
      </tr> 
      <tr> 
       <td>Date de fin&nbsp;:<span style="font-weight: bolder; color: red;">&nbsp;&#42;</span></td> 
       <td> 
        <input type="text" name="dateFin" size="10" maxlength="10" id="date2" value="" 
          required="required"> 
       </td> 
      </tr> 

      <tr> 
       <td><font size="3">Charg&eacute;(e)(s)</td> 
       <td> 
        <select name="chargeMatricule"> 
         <option value="0" selected></option> 
         <% for (Utilisateur u : utilisateurs) {%> 
         <option value="<%=u.getUtilisateurMatricule()%>"><%=u.getUtilisateurNom() + ", " + u.getUtilisateurPrenom()%></option> 
         <%}%> 
        </select> 
       </td> 
      </tr> 
      <tr> 
       <td><font size="3">Activit&eacute;&nbsp;:&nbsp;</td> 
       <td> 
        <select name="activiteNom"> 
         <option value="0" selected></option> 
         <% for (String s : activites) {%> 
         <option value="<%=s%>"><%=s%></option> 
         <%}%> 
        </select> 
       </td> 
      </tr> 
      <td colspan='5' align="center"> 
       <input type="submit"> 
      </td> 
      </tr> 
     </form> 
    </div> 
</td> 

내 조치 :

public class ActionStatistiques extends DispatchAction { 

public ActionForward module1(ActionMapping mapping, ActionForm form, 
     HttpServletRequest request, HttpServletResponse response) 
     throws Exception { 
    FormStatMod1 forms = (FormStatMod1) form; 
    ServiceStatistiques service = new ServiceStatistiques(); 
    String dd = forms.getDateDebut(); 
    String dateDebut = dd.substring(6, 10) + '-' + dd.substring(3, 5) + '-' + dd.substring(0, 2); 
    String df = forms.getDateFin(); 
    String dateFin = df.substring(6, 10) + '-' + df.substring(3, 5) + '-' + df.substring(0, 2); 
    Collection[] collections = service.module1(forms.getChoixEtat(), dateDebut, dateFin); 
    Collection<Flux> listef = collections[1]; 
    String activiteNom = forms.getActiviteNom(); 
    String chargeMatricule = forms.getChargeMatricule(); 

희망, 사람이 무엇이 잘못되었는지 볼 수 있습니다. 좋은 하루 되세요 !! 여기 <html:form>

+1

???? JSP에는 Struts 태그가없고 일반 HTML/JSP 만 포함됩니다. 튜토리얼을 따라 해 보셨습니까? – SJuan76

+0

struts 태그를 추가 할 필요가 없습니다. 양식에 다음이 포함되어 있습니다. form action = "statistiques.do". 그리고 나는 struts-config 파일에 선언 된 액션 폼을 사용하고 있습니다 !!! – washint31

답변

0

좋아요. 내 길을 찾았습니다. 여러 번처럼 그것은 바보 같은 누락이었다. .. 세터는 나의 형에서 놓쳤다! !! 그것을 확인하는 것을 결코 잊지 마십시오.

0

사용은 예입니다 - 일반적으로 양식 스트럿츠 태그를 사용하여 렌더링 http://struts.apache.org/release/1.3.x/faqs/actionForm.html

+0

이미이 솔루션을 사용해 보았지만 작동하지 않습니다 ...하지만 아이디어에 감사드립니다. 좋은 하나를 빨리 발견하기를 바란다! !!! – washint31

0

하지만 당신은 입력 필드를 채우는 데 JSP EL 표현을 사용할 수 있습니다. 예 :

<input type="text" name="dateFin" size="10" maxlength="10" id="date2" value="${formStatMod1.dateFin}" required="required"> 
+0

하지만 나는 그것을 사용한 적이 없으며 스트럿츠 액션 폼에 문제가 없었습니다 !! 나는 그것을 시도했지만 슬프게도 작동하지 않는다 ... 나는이 문제에 대한 해결책을 찾기가 매우 흥미로운데, 이는 이것이 나의 응용 프로그램을 끝내기 위해 놓친 마지막 문제 중 하나이기 때문이다 ... 당신의 대답에 대해 많은 감사를드립니다 !! – washint31

+0

최소한 struts-config.xml을 게시하여 빈이 요청으로 채워지는 양식을 알 수 있습니다. –

관련 문제