Search code examples
javaspringportletspring-portlet-mvc

Spring MV Porlet ActionMapping is not working


I have a simple login form with a controller in Spring MVC Portlet framework. Form looks like this

<portlet:actionURL var="loginAction">
    <portlet:param name="action" value="login" />
</portlet:actionURL>

<div class="portlet-section-body">
    <form:form name="loginForm" method="post" action="${loginAction}" commandName="loginForm" >
        <table>
            <tr>
                <td><span class="portlet-form-field-label">Username: </span></td>
                <td><form:input class="portlet-form-input-filed" path="login" /></td>
                <td><form:errors path="login" /></td>
            </tr>
            <tr>
                <td><span class="portlet-form-field-label">Password: </span></td>
                <td><form:input class="portlet-form-input-filed" path="password" /></td>
            </tr>
            <tr>
                <td><input class="portlet-form-button" type="submit" value="Login"/></td>
            </tr>
        </table>
    </form:form>
 </div>

and the controller

@Controller
@RequestMapping(value="VIEW")
public class LoginController {

    @RenderMapping("render=showBookListPage")
    public String showBookListPage() {
        return "bookList";
    }

    @ActionMapping(params="action=login")
    public void loginUser(ActionResponse response) {
        response.setRenderParameter("render", "showBookListPage");
    }

    @ModelAttribute("loginForm")
    public LoginForm getLoginForm() {
        return new LoginForm();
    }
}

And the problem is - when I submit the form, I get redirected to page /bookShop-1.0/portal/classic/showcase/somePortalGeneratedString which is wrong because my portlet is on localhost:8080/portal/classic/showcase URL so I get 404 error. <portlet:renderURL> tag and mapping is working correctly but I can't simply get this form working.

My environment is: JBoss JPP 6.0 (based on GateIn 3.5), Spring 3.2.1 and Portlet 2.0


Solution

  • This is a bug in Spring 3.2.1 and 3.2.2 : https://jira.springsource.org/browse/SPR-10382

    The fix is planned for 3.2.3. Meanwhile you can downgrade to 3.2.0.