Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.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
Spring 如何在进入JSP页面之前设置表单Bean_Spring_Spring Mvc_Liferay_Portlet_Liferay 6 - Fatal编程技术网

Spring 如何在进入JSP页面之前设置表单Bean

Spring 如何在进入JSP页面之前设置表单Bean,spring,spring-mvc,liferay,portlet,liferay-6,Spring,Spring Mvc,Liferay,Portlet,Liferay 6,我是个十足的初学者。所以,如果我错过了显而易见的事情,请原谅我 我正在使用的环境:SpringPortletMVC(3.0)、Liferay 6.0.6 我有一个控制器、一个表单bean和一个JSP页面。 通过使用下面的代码,我能够成功地提交表单并获得表单bean。然而,在将bean转发到JSP之前,我一直在研究如何将一些值预加载到表单bean中。有人能指出正确的方向吗: 我的控制器: @ActionMapping(params = "spring_action=resetPasswordVie

我是个十足的初学者。所以,如果我错过了显而易见的事情,请原谅我

我正在使用的环境:SpringPortletMVC(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();
}

在呈现方法resetPasswordView中,将名为resetPasswordCriteria(jsp中的commandName)的类型为ResetPassword的对象放置到模型中。

。。。@RenderMapping(params=“spring\u render=resetPasswordViewRender”)受保护的模型和视图resetPasswordViewRender(@ModelAttribute(“resetPasswordCriteria”)最终ResetPassword resetPasswordCriteria,RenderRequest RenderRequest,映射模型)
<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
}