从jsp到controller,所有元素的值都为null

时间:2013-12-02 10:34:34

标签: java spring-mvc portlet liferay-6

我正在使用portlet,我使用spring mvc和java。 在以下代码中 我得到了所有需要的元素的值,但在运行时所有值都为null 巫婆由jsp的控制者带走。

请尽快帮助我。

在控制器中:

@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");
    }

在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>

1 个答案:

答案 0 :(得分:0)

由于您的表单的enctype类型为mulitpart,因此您可以通过uploadRequest获取表单参数。

通过以下代码获取上传请求,然后从中获取参数。

UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(request);