0

私は全くの初心者です。ですから、当たり前のことを見逃してしまったら、我慢してください。

私が使用している環境:Spring Portlet MVC(3.0)、Liferay 6.0.6

コントローラ、フォームBean、JSPページがあります。以下のコードを使用して、フォームを正常に送信し、フォームBeanを取得できます。ただし、BeanがJSPに転送される前に、フォームBeanにいくつかの値をプリロードする方法に固執しています。誰かが正しい方向を指摘できますか?

私のコントローラー:

@ActionMapping(params = "spring_action=resetPasswordViewAction")
protected void resetPasswordAction(ActionRequest actionRequest, Map<String, Object> model, ActionResponse actionResponse, @RequestParam String customerId, @RequestParam String userName) {
    model.put("customerId", customerId);//Preload form bean value with this
    model.put("userName", userName);//Preload form bean value with this
    actionResponse.setRenderParameter("spring_render", "resetPasswordView");
}

@RenderMapping(params = "spring_render=resetPasswordView")
protected ModelAndView resetPasswordView(RenderRequest renderRequest, Map<String, Object> model) {
    return new ModelAndView("resetPassword", model);
}

@ActionMapping(params = "spring_action=resetPasswordUpdateAction")
protected void resetPasswordUpdateAction(ActionRequest actionRequest, Map<String, Object> model, ActionResponse actionResponse, final ResetPassword resetPasswordCriteria) {
    LOG.info(resetPasswordCriteria.toString());// Form values are retrieved successfully
    actionResponse.setRenderParameter("spring_render", "resetPasswordView");
}

@ModelAttribute("resetPasswordCriteria")
public ResetPassword getResetPasswordCriteria() {
    return new ResetPassword();
}

私のJSPページ:

<form:form id="resetPasswordForm" name="resetPasswordForm" commandName="resetPasswordCriteria" method="post" action="${resetPasswordUpdateActionURL}">

    <form:label path="customerId" /><!--Preload this field value-->
    <form:label path="userName" /><!--Preload this field value-->
    <form:password path="password" />
    <form:password path="confirmPassword" />
    <input type="submit" value="Submit" />

</form:form>

フォームビーン:

public class ResetPassword {
    private String customerId = "";
    private String userName = "";
    private String password = "";
    private String confirmPassword = "";
    //Getters Setters
}
4

1 に答える 1

1

レンダリングメソッドresetPasswordViewで、 ResetPasswordタイプのresetPasswordCriteria(jspではcommandName)という名前のオブジェクトをモデルに配置します。

于 2011-10-27T10:52:16.080 に答える