栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Spring Portlet MVC中的一系列重复形式

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Spring Portlet MVC中的一系列重复形式

这就是我解决问题的方式。我没有一个用于保存每个迭代特定数据的反馈表单的列表,而是必须创建一个包含

Feedback
域对象列表的单个反馈表单。

FeedbackForm
现在看起来像这样:

public class FeedbackForm {    private List<Feedback> feedbacks;    ...    getters and setters}

通常,

Feedback
该类如下所示:

public class Feedback {    private String feedback;    private int rating;    ...    getters and setters}

现在我的JSP看起来像:

<portlet:actionURL var="saveURL">    <portlet:param name="action" value="save" />    <portlet:param name="index" value="${stat.index}" /></portlet:actionURL><c:forEach var="employee" items="${employees}" varStatus="stat">    <form:form action="${saveURL}" method="post" modelAttribute="feedbackForm">        <form:input path="feedbacks[${stat.index}].feedback" />        <form:input path="feedbacks[${stat.index}].rating" />        <input type="submit" value="Submit Feedback"/>    </form:form></c:forEach>

最后,我的控制器方法如下所示:

@RequestMapping(params = "action=save")public void saveFeedback(ActionRequest request, ActionResponse response,    @RequestParam("index") int index,    @ModelAttribute("feedbackForm") FeedbackForm feedbackForm, Model model)    throws PortletException {    Feedback feedback = feedbackForm.getFeedbacks().get(index);    logger.debug("Submitted feedback is {}", feedback);}

这样的想法是不可能同时提交多个表单,尽管它们可能同时出现在页面上。基本上,每个表单只能单击一个提交按钮。

希望这对处于类似情况的人有所帮助。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/670856.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号