小编vam*_*shi的帖子

Spring portlet mvc在提交编辑表单期间验证失败

我有一个几乎没有验证的表格.在新表单提交期间,如果验证失败,我可以看到这些错误消息.但是,在我有意地将字段更改为空白并且提交表单时编辑表单期间,Jsp页面上没有显示错误消息,但我可以将控制器中的错误数量设置为1.

<portlet:actionURL var="actionUrl">
    <portlet:param name="action" value="editCommunity"/>
    <portlet:param name="communityID" value="${community.id}"/>
</portlet:actionURL>

<liferay-ui:tabs names="Details" />

<form:form commandName="community" method="post" action="${actionUrl}">
    <form:hidden path="id"/>

    <div><form:errors cssClass="portlet-msg-error" path="*"/></div>

    <table class="manager-detail">
        <tr>
            <th class="portlet-form-field-label">
                <label for="community_label_name"><spring:message code="community.label.name"/></label>         
                <span class="manager-field-required">*</span>
            </th>
            <td><form:input id="community_label_name" cssClass="portlet-form-input-field" path="name" size="30" maxlength="80" /></td>
        </tr>
Run Code Online (Sandbox Code Playgroud)

我的编辑控制器方法.....

渲染编辑表格

@RequestMapping(params = "action=editCommunity")
public String showEditCommunityForm(final RenderRequest request,
        @RequestParam(value="communityID") Long id, final Model model)
        throws CommunityNotFoundException {
    final ThemeDisplay themeDisplay = (ThemeDisplay) request
            .getAttribute(WebKeys.THEME_DISPLAY);

    model.addAttribute("community", communityService.getCommunity(id));


    return "communityEdit";
}
Run Code Online (Sandbox Code Playgroud)

编辑的表格已提交

@RequestMapping(params = "action=editCommunity")
public void submitEditCommunityForm(final ActionRequest …
Run Code Online (Sandbox Code Playgroud)

validation model-view-controller spring portlet

2
推荐指数
1
解决办法
3596
查看次数