Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SpringMVC:jsp中未声明为表单字段的表单支持Bean属性设置为null_Spring_Spring Mvc - Fatal编程技术网

SpringMVC:jsp中未声明为表单字段的表单支持Bean属性设置为null

SpringMVC:jsp中未声明为表单字段的表单支持Bean属性设置为null,spring,spring-mvc,Spring,Spring Mvc,我在学习春季mvc。我开发了一个屏幕,在登录时会显示用户的个人数据。在同一屏幕上会有更新按钮来更新个人数据 我的问题是,在personaldata.jsp中,用户属性(如用户名、密码)在表单提交后被设置为null,而这些属性没有作为表单字段提及 下面是我的personaldata.jsp <form:form name="customerForm" id="customerForm" commandName="customerForm" method="post" >

我在学习春季mvc。我开发了一个屏幕,在登录时会显示用户的个人数据。在同一屏幕上会有更新按钮来更新个人数据

我的问题是,在personaldata.jsp中,用户属性(如用户名、密码)在表单提交后被设置为null,而这些属性没有作为表单字段提及

下面是我的personaldata.jsp

  <form:form name="customerForm" id="customerForm" commandName="customerForm" method="post" >
            <form:hidden path="userName" id="userName"/>
             <form:hidden path="emailAddress" id="emailAddress"/>
             <form:hidden path="password" id="password"/>
            <div class="faq_rightin">
                <div class="faq_icon"><img src='<c:url value="/images/icon19.png" />' alt=""></div>
                <div class="faq_ohc2">
                    <h1><spring:message code="myaccount.label.personaldata" text="Personal Data"></spring:message></h1>
                    <span class="common ul-font-style m_top ">Welcome ${customerForm.firstName} ${customer.lastName}</span>
                    <span class="red"><spring:message code="myaccount.label.personalinfodesc" text="You may here enter your personal Information, enabling you to use those when you make your next booking. Doing so, your user experience is better, quicker."></spring:message></span>
                    <div class="m_top pd-form-box">
                        <div class="comm_md m_top float-left">
                            <div class="pd-colum1 mrg-rgt10">
                                <span class="pd-name-title mrg-rgt10">
                                    <select class="select-pd-name1" id="delivery_method" >
                                        <option class="select-pd-name1" value="0">Mr</option>
                                        <option value="1">Mrs</option>
                                        <option value="2">Miss</option>
                                    </select>
                                </span>
                                <span>
                                    <spring:message code="myaccount.label.firstname" text="First Name" var="firstname" />
                                    <form:input path="firstName" id="firstName" cssClass="pd-form-txt-common pd-txt1 float-left shadow"  placeholder="${firstname}*" />
                                </span>
                            </div>
                            <div class="pd-colum2 ">
                                <spring:message code="myaccount.label.familyname" text="Family Name" var="lastname"></spring:message>
                                <form:input path="lastName" id="lastName" cssClass="pd-form-txt-common pd-txt2 float-left shadow"  placeholder="${lastname}*" />
                            </div>
                        </div><!--end row -->

                        <div class="comm_md m_top float-left">
                            <div class="pd-colum1 mrg-rgt10">
                                <div class="comm_md float-left">
                                    <spring:message code="myaccount.label.emailaddress" text="Email-Address"></spring:message>* : ${customerForm.emailAddress}
                                </div>
                                <a href="#" class="comm_md blue_txt bold float-left"><spring:message code="myaccount.label.changeyouremailaddress" text="Change your Email Address"></spring:message> &gt;</a>                                
                            </div>
                            <div class="pd-colum2 ">
                                <div class="comm_md float-left">
                                    <spring:message code="myaccount.label.birthday" text="Birthday"></spring:message>*
                                </div>
                                <div class="comm_md float-left">
                                    <!--<form method="post" action="">  
                                        <div class="select_md3 float-left">
                                            <form:select path="day" id="" cssClass="select2">
                                                <form:option value="1">1</form:option>
                                                <form:option value="2">2</form:option>
                                                <form:option value="3">3</form:option>
                                                <form:option value="4">4</form:option>
                                            </form:select>
                                        </div>
                                    </form>-->
                                    <div class="select_md3 float-left">
                                        <form:select path="day" id="birthDay" cssClass="select2" items="${days}"/>
                                    </div>

                                    <span class="float-left f13 p_5">/</span>  
                                    <!--<form method="post" action="">  
                                        <div class="select_md3 float-left">
                                             <form:select path="month" id="" cssClass="select2">
                                                <form:option value="1">1</form:option>
                                                <form:option value="2">2</form:option>
                                                <form:option value="3">3</form:option>
                                                <form:option value="4">4</form:option>
                                            </form:select>
                                        </div>
                                    </form>-->
                                    <div class="select_md3 float-left">
                                        <form:select path="month" id="birthMonth" cssClass="select2" items="${months}"/>
                                    </div>
                                    <span class="float-left f13 p_5">/</span>
                                    <!--<form method="post" action="">  
                                        <div class="select_md4 float-left">
                                             <form:select path="year" id="" cssClass="select2">
                                                <form:option value="1">2011</form:option>
                                                <form:option value="2">2012</form:option>
                                                <form:option value="3">2013</form:option>
                                                <form:option value="4">2014</form:option>
                                             </form:select>
                                        </div>
                                    </form> -->
                                    <div class="select_md4 float-left">
                                        <form:select path="year" id="birthYear" cssClass="select2" items="${years}"/>
                                    </div>
                                </div>
                            </div>
                        </div><!--end row -->

                        <div class="comm_md m_top float-left">
                            <div class="pd-colum1 mrg-rgt10">
                                <span>
                                    <spring:message code="myaccount.label.code" text="Code" var="phonecode"></spring:message>
                                    <form:input path="phoneCode" id="phoneCode" cssClass="pd-form-txt-common pd-txt3 float-left mrg-rgt10 shadow" placeholder="${phonecode}"/>
                                </span>
                                <span>
                                    <spring:message code="myaccount.label.phonenumber" text="Phone Number" var ="phonenumber"></spring:message>
                                    <form:input path="phoneNumber" id="phoneNumber" cssClass="pd-form-txt-common pd-txt1 float-left shadow" placeholder="${phonenumber}"/>
                                </span>
                            </div>
                            <div class="pd-colum2 ">
                                <span>
                                    <spring:message code="myaccount.label.code" text="Code" var="mobileCode"></spring:message>
                                    <form:input path="mobileCode" id="mobileCode" cssClass="pd-form-txt-common pd-txt3 float-left mrg-rgt10 shadow" placeholder="${mobileCode}"/>
                                </span>
                                <span>
                                    <spring:message code="myaccount.label.mobilenumber" text="Mobile Number" var="mobileNumber"></spring:message>
                                    <form:input path="mobileNumber" id="mobileNumber" cssClass="pd-form-txt-common pd-txt4 float-left shadow"  placeholder="${mobileNumber}*"/>
                                </span>
                            </div>
                        </div><!--end row -->

                        <div class="comm_md m_top float-left">
                            <div class="pd-colum1 mrg-rgt10">
                                <form:select path="idDocument" cssClass="select-pd-name" id="idDocument">
                                    <form:option value="0"><spring:message code="myaccount.label.identificationdocument" text="Identification Document"></spring:message></form:option>
                                    <form:option value="1"><spring:message code="myaccount.label.passport" text="Passport"></spring:message></form:option>
                                    <form:option value="2"><spring:message code="myaccount.label.license" text="License"></spring:message></form:option>
                                </form:select>
                            </div>
                            <div class="pd-colum2 ">
                                <span class="f13 bold"><spring:message code="myaccount.label.invoiceaddressforcompanies" text="Invoice Address for Companies"></spring:message></span>
                            </div>
                        </div><!--end row -->

                        <div class="comm_md m_top float-left">
                            <div class="pd-colum1 mrg-rgt10">
                              <form:input path="idNumber" cssClass="pd-form-txt-common pd-txt5 float-left shadow" placeholder="Ausweisnumber*"/>
                            </div>
                            <div class="pd-colum2 ">
                                <input type="checkbox" name="" class="mrgrgt5" id=" "><span class="f13"><spring:message code="myaccount.label.sameasmailaddress" text="Same as mail Address"></spring:message> </span>
                            </div>
                        </div><!--end row -->

                        <div class="comm_md m_top float-left">
                            <div class="pd-colum1 mrg-rgt10">
                                <span class="f13 bold"><spring:message code="myaccount.label.address" text="Address"></spring:message></span>
                            </div>
                            <div class="pd-colum2 ">
                                <span>
                                    <spring:message code="myaccount.label.companyname" text="Company Name" var="companyname"></spring:message>
                                    <form:input id="companyName" path="companyName" class="pd-form-txt-common pd-txt2 float-left mrg-rgt10 shadow" placeholder="${companyname}"/>
                                </span>                       
                            </div>
                        </div><!--end row -->

                        <div class="comm_md m_top float-left">
                            <div class="pd-colum1 mrg-rgt10">
                                <span>
                                      <spring:message code="myaccount.label.street" text="Street" var="${street}"></spring:message>
                                      <form:input path="address.street" id="street" cssClass="pd-form-txt-common pd-txt1 float-left mrg-rgt10 shadow" placeholder="${street}"/>
                                </span>
                                <span>
                                    <form:input path="address.streetNo" id="streetNo" cssClass="pd-form-txt-common pd-txt3 float-left shadow" placeholder="No"/>
                                </span>
                            </div>
                            <div class="pd-colum2 ">                                
                                <span>
                                    <spring:message code="myaccount.label.street" text="Street" var="street"></spring:message>
                                    <form:input path="address.companyStreet" id="compStreet" cssClass="pd-form-txt-common pd-txt4 float-left mrg-rgt10 shadow" placeholder="${street}"/>
                                </span>
                                <span>
                                    <form:input path="address.companyStreetNo" id="compStreetNo" cssClass="pd-form-txt-common pd-txt3 float-left shadow" placeholder="No"/>
                                </span>
                            </div>
                        </div><!--end row -->

                        <div class="comm_md m_top float-left">
                            <div class="pd-colum1 mrg-rgt10">
                                <span>
                                    <spring:message code="myaccount.label.plz" text="PLZ" var="zip"></spring:message>
                                    <form:input path="address.postalCode" id="postalCode" cssClass="pd-form-txt-common pd-txt3 float-left mrg-rgt10 shadow" placeholder="${zip}"/>
                                </span>
                                <span>
                                    <spring:message code="myaccount.label.town" text="Town" var="compcity"></spring:message>
                                    <form:input path="address.city" id="city" cssClass="pd-form-txt-common pd-txt1 float-left shadow" placeholder="${compcity}"/>
                                </span>
                            </div>
                            <div class="pd-colum2 ">
                                <span>
                                    <spring:message code="myaccount.label.plz" text="PLZ" var="plzcomp"></spring:message>
                                    <form:input path="address.companyPostalCode" id="compPostalCode" cssClass="pd-form-txt-common pd-txt3 float-left mrg-rgt10 shadow" placeholder="${plzcomp}"/>
                                </span>
                                <span>
                                    <spring:message code="myaccount.label.town" text="Town" var="comtown"></spring:message>
                                    <form:input path="address.companyCity" id="compCity" cssClass="pd-form-txt-common pd-txt4 float-left shadow" placeholder="${comtown}"/>
                                </span>                         
                            </div>
                        </div><!--end row -->

                        <div class="comm_md m_top float-left">
                            <div class="pd-colum1 mrg-rgt10">
                                <!--<select class="select-pd-name" id="delivery_method" >
                                    <option class="select-pd-name" value="0"><spring:message code="myaccount.label.country" text="Country"></spring:message></option>
                                    <option value="1">England</option>
                                    <option value="2">Irland</option>
                                </select> -->
                                <spring:message code="myaccount.label.country" text="Country" var="country"></spring:message>
                                <form:input path="address.country" id="country" cssClass="select-pd-name" placeholder="${country}"/>
                            </div>
                            <div class="pd-colum2 ">
                                <!--  <select class="select-pd-name" id="delivery_method" >
                                    <option class="select-pd-name" value="0"><spring:message code="myaccount.label.country" text="Country"></spring:message></option>
                                    <option value="1">England</option>
                                    <option value="2">Irland</option>
                                </select>-->
                                <spring:message code="myaccount.label.country" text="Country" var="compCountry"></spring:message>
                                <form:input path="address.companyCountry" id="compCountry" cssClass="select-pd-name" placeholder="${compCountry}"/>
                            </div>
                        </div><!--end row -->                                               

                        <div class="comm_md m_top float-left">
                            <div class="pd-colum1 mrg-rgt10">
                                <select class="select-pd-name" id="delivery_method" >
                                    <option class="select-pd-name" value="0"><spring:message code="myaccount.label.eticketidentification" text="E-ticket Identification"></spring:message></option>
                                    <option value="1">England</option>
                                    <option value="2">Irland</option>
                                </select>
                            </div>
                            <div class="pd-colum2 flt-rgt ">
                                <spring:message code="myaccount.label.vatnumber" text="VAT Number" var="vatNumber"></spring:message>
                                <form:input path="vatNumber" id="vatNumber" cssclass="pd-form-txt-common pd-txt2 float-left mrg-rgt10 shadow" placeholder="${vatNumber}"/>
                            </div>
                        </div><!--end row -->

                        <div class="comm_md m_top float-left">
                            <div class="pd-colum1 mrg-rgt10">
                                <span class="f13 blue_txt"><b>*</b><spring:message code="myaccount.label.fieldsmustbefilledout" text="Fields must be filled out"></spring:message></span>
                            </div>
                            <div class="pd-colum2 flt-rgt ">
                                <input type="checkbox" name="" class="mrgrgt5"><span class="f13"><spring:message code="myaccount.label.futureinformationsofspecialofferings" text="I want to have in future informations about special of ferings for t4b customers."></spring:message> </span>
                            </div>
                        </div><!--end row -->

                        <div class="comm_md m_top float-left">
                            <div class="pd-colum1 mrg-rgt10">
                                <select class="select-pd-name" id="delivery_method" >
                                    <option class="select-pd-name" value="0"><spring:message code="myaccount.label.languagepreferred" text="Language ,Preferred"></spring:message></option>
                                    <option value="1">Sizilian</option>
                                    <option value="2">English</option>
                                </select>
                            </div>
                            <div class="pd-colum2 flt-rgt ">
                                <input type="submit" name="" id="store" class="common-btn float-right" value="<spring:message code="myaccount.label.store" text="Store"></spring:message>" />
                            </div>
                        </div><!--end row -->

                    </div><!--end pd-form-box -->                      
                </div>
            </div>
          </form:form>

“alt=”“>
欢迎${customerForm.firstName}${customer.lastName}
先生
夫人
错过
*:${CustomPerform.emailAddress}
*
/  
/
@RequestMapping(value = "/personaldata", method = RequestMethod.GET)
    public String personalData(Map<String, Object> map,
            HttpServletRequest request, Principal principal) {
        logger.info("Default Page");

        try {
            String userName = principal.getName();
            logger.debug("*******User name: " + userName);
            CustomerVO customerVO = customerService.findByUserName(userName);
            map.put("customerForm", customerVO);
        } catch (T4BException e) {
            logger.error(e.getLocalizedMessage());
        }
        /*
         * map.put("search", searchVO); if
         * (request.getParameter("ajax_get_standard_content") != null &&
         * request.getParameter("ajax_get_standard_content").equals("on")) {
         * return "home.definition.ajax"; } else { return "home.definition"; }
         */
        return "myaccount.personaldata";
    }
    @RequestMapping(value = "/storepersonal", method = RequestMethod.POST)
        public String storePersonal(@ModelAttribute("customerForm")CustomerVO customerVO , Map<String, Object> map,
                HttpServletRequest request, HttpSession session,Principal principal) {
        try {
            customerService.updateCustomer(customerVO);
            //map.put("customerForm", customerService.findByUserName(customerVO.getUserName()));
        } catch (T4BException e) {
            logger.error(e.getLocalizedMessage());
        }

    logger.info("Store Personal Page");
    /*
     * map.put("search", searchVO); if
     * (request.getParameter("ajax_get_standard_content") != null &&
     * request.getParameter("ajax_get_standard_content").equals("on")) {
     * return "home.definition.ajax"; } else { return "home.definition"; }
     */
    return "myaccount.personaldata";
} 
@RequestMapping(value="/owners/{ownerId}/pets/{petId}/edit", method = RequestMethod.POST)
public String processSubmit(@ModelAttribute Pet pet) {

}
@ModelAttribute("foo")
private Foo prepareFoo() {
    // get the foo to update from the database and return it.
    // Spring will store it in the model
}

@RequestMapping(...)
public ModelAndView submitForm(@ModelAttribute("foo") Foo foo) {
    // Spring will pass the Foo that has been prepared and stored in the model,
    // updated with the values submitted in the HTML form
}