简体   繁体   中英

from jsp to controller , value of all elements is null

I m working with portlet and I use spring mvc and java. In the following code I get the value of all elements that are needed but at run time all values are null witch are taken by controller from jsp.

please help me as soon as possible.

In Controller:

@ActionMapping(params="myaction=OrderRegister")
void OrderRegister(ActionRequest request,ActionResponse response)
        throws IOException
{
     System.out.println("I love dear neda :* ");        

    TblSection sectionObj=orderServices.getSectionId(Long.parseLong(request.getParameter("searchSection")));
    Long subId=Long.parseLong(request.getParameter("searchSubsection"));       
    Long secId=sectionObj.getId();      
    TblSubsection SubsectionObj=orderServices.getSubsectionId(secId,subId);
    String TitleDivOrder=request.getParameter("InputTitleDivOrder").toString();
    String DescriptionDivOrder=request.getParameter("TextDescriptionDivOrder").toString();
    String DivMaxDeliveryDate=request.getParameter("InputMaxDeliveryDate").toString();
    String InputSuggestedPrice=request.getParameter("InputSuggestedPrice").toString();


    TblOrder ObjOrder=new TblOrder();
    ObjOrder.setTblSection(sectionObj);
    ObjOrder.setTblSubsection(SubsectionObj);
    ObjOrder.setTitle(TitleDivOrder);
    ObjOrder.setDescription(DescriptionDivOrder);
    ObjOrder.setMaxDateOfDeliveryCustomer(DivMaxDeliveryDate);
    ObjOrder.setCustomerPrice(Long.parseLong(InputSuggestedPrice));

    Long Ids=orderServices.registerOrder(ObjOrder);

    response.setRenderParameter("render", "RegisterOrder");
    }

in jsp:

<form:form  method="post" action="${OrderRegisterURL}" enctype="multipart/form-data">


<div id="OrderTypeDiv" class="OrderTypeDiv DivRow">
<div class="width100 Right"></div>
<div class="width125 Right">
    <input id="addi" checked="checked" type="radio" value="1"           class="OrderTypeRadio Right Margin-L" name="orderType"/>
</div>
<div class="width125 Right">
    <input id="vije" type="radio" value="1" class="OrderTypeRadio Right Margin-   L" name="orderType"/>
</div>
<div class="width125 Right">
    <input id="khodEjraei" type="radio" value="1" class="OrderTypeRadio Right        Margin-L" name="orderType"/>
</div>
</div>

<div class="DivOrderTypeHelp">
<span class="OrderName" >:</span> <span> </span>
</div>

<div class="SectionDiv DivRow">
<div class="width100 Right"></div>
<select class="width100" id="comboSection" name="searchSection">
    <option selected="selected" disabled="disabled"></option>
    <c:forEach var="section" items="${sections}">
          <option value="${section.id}">
                <c:out value="${section.title}" />
          </option>
    </c:forEach>
</select>
</div>



<div class="SubSectionDiv DivRow">
<div class="width100 Right"></div>
<select  class="width100" id="comboSubSection" name="searchSubsection">
       <option selected="selected" disabled="disabled"></option>
 </select>
</div>




<div class="TitleDiv DivRow" id="TitleDivOrder" name ="TitleDivOrder">
<div class="width100 Right"></div>
<input id="InputTitle" name="InputTitleDivOrder" class="Width380">

</div>
<div class="DescriptionDiv DivRow" id="DescriptionDivOrder" name="DescriptionDivOrder">
<div class="width100 Right"></div>
<textarea name="TextDescriptionDivOrder"  class="Width250 TextArea"></textarea>

</div>


<div id="DivSubmit" class="DivRow">

<input type="submit" id="SubmitButton" value="send">
 </div>


</form:form>

As your form has enctype as mulitpart, you can get form parameters by uploadRequest.

Get upload request by code below and then get parameters from it.

UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(request);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM