0

get Request Params のために 2 つのモデル (users と userData) を結合したいのですが、結果として空白の画面が表示されました。私のコードの問題は何ですか?

Register オブジェクトは ModelAttribute です

users および userData モデルにはいくつかのフィールドがあります。

データ モデル

public class Register {
    private Users users;
    private UserData userData;
//getters and setters
}

register.jspx

<form:form action="register" method="post" commandName="register">
            <fieldset>
                <div class="span12">
                    <legend>Sign Up as a Merchant</legend>
                </div>
                <form:input type="hidden" path="enabled" value="true"/>
                <div class="span6">
                    <div class="control-group" id="usernameCtl">
                        <label class="control-label" for="username">Username</label>
                        <div class="controls">
                            <form:input type="text" class="input-xlarge" id="username" path="users.username"/>
                            <form:errors path="users.username"/>
                        </div>
                    </div>
                    <div class="control-group" id="passwordCtl">
                        <label class="control-label" for="password">Password</label>

                        <div class="controls">
                            <form:input type="password" class="input-xlarge" id="password" path="users.password"/>
                            <form:errors path="users.password"/>
                        </div>
                    </div>
                    <div class="control-group" id="confirmCtl">
                        <label class="control-label" for="confirm">Confirm</label>
                        <div class="controls">
                            <form:input type="password" class="input-xlarge" id="confirm" name="confirm"/>
                        </div>
                    </div>
                    <div class="control-group" id="emailCtl">
                        <label class="control-label" for="email">Email</label>
                        <div class="controls">
                            <form:input type="text" class="input-xlarge" id="email" path="userData.email"/>
                            <form:errors path="userData.email"/>
                        </div>
                    </div>

                </div>
                <div class="span6">
                    <div class="control-group" id="nameCtl">
                        <label class="control-label" for="name">Name</label>
                        <div class="controls">
                            <form:input type="text" class="input-xlarge" id="name" path="userData.name"/>
                            <form:errors path="userData.name"/>
                        </div>
                    </div>
                    <div class="control-group" id="surnameCtl">
                        <label class="control-label" for="surname">Surname</label>
                        <div class="controls">
                            <form:input type="text" class="input-xlarge" id="surname" path="userData.surname"/>
                            <form:errors path="userData.surname"/>
                        </div>
                    </div>

                    <div class="control-group" id="IDNumberCtl">
                        <label class="control-label" for="streetAddress">Id Number</label>
                        <div class="controls">
                            <form:input type="text" class="input-xlarge" id="idNumber" path="userData.idNumber"/>
                            <form:errors path="userData.idNumber"/>
                        </div>
                    </div>
                    <div class="control-group" id="FactoryCtl">
                        <label class="control-label" for="city">Factory</label>
                        <div class="controls">
                            <form:select path="userData.factory">
                                <form:options itemValue="id" itemLabel="name" items="${factory}" />
                            </form:select>-->
                        </div>
                    </div>

                    <div class="control-group" id="IssueSectionCtl">
                        <label class="control-label" for="state">IssueSection</label>
                        <div class="controls">
                            <form:select path="userData.issueSection">
                                <form:options itemValue="id" itemLabel="name" items="${issueSection}" />
                            </form:select>-->
                        </div>
                    </div>

                    <input class="btn btn-primary btn-large" type="submit" value="Register"/> &nbsp; &nbsp;
                    <a href="${pageContext.request.contextPath}/" class="btn btn-large ">Cancel</a>

                </div>
            </fieldset>
        </form:form>

UsersController_Roo_Controller

@RequestMapping(method = RequestMethod.POST, produces = "text/html",value = "/register")
    public String UsersController.register(@ModelAttribute("register") Register register, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
        if (bindingResult.hasErrors()) {
            populateRegisterForm(uiModel, register);
            return "userses/register";
        }
        uiModel.asMap().clear();
        //users.setUserData(userData);
      register.getUsers().persist();
        return "redirect:/userses/" + encodeUrlPathSegment(register.getUsers().getId().toString(), httpServletRequest);
    }

@RequestMapping(params = "register", produces = "text/html")
    public String UsersController.registerForm(Model uiModel) {
        populateRegisterForm(uiModel, new Register());
        return "userses/register";
    }


void UsersController.populateRegisterForm(Model uiModel, Register register) {
        uiModel.addAttribute("factory", Factory.findAllFactorys());
        uiModel.addAttribute("issueSection", IssueSection.findAllIssueSections());
        uiModel.addAttribute("register",register);
    }
4

1 に答える 1