1

我以前有一个登录表单,如下所示

<div class="span-10 last">
    <c:url value="/j_spring_security_check" var="loginActionUrl" />
    <user:login   actionNameKey="login.login" action="${loginActionUrl}"/>
</div>

但现在我将表格更改为如下所示。

<div class="span-10 last">
    <c:url value="/login/loginNow" var="loginActionUrl" />
    <user:login actionNameKey="login.login" action="${loginActionUrl}"/>
</div>

我的控制器现在看起来像这样

@Controller
@RequestMapping(value = "/login")
public class LoginPageController {
    @RequestMapping(value = "/loginNow", method = RequestMethod.POST)
    public String doLogin(
        @RequestHeader(value = "referer", required = false) final String referer,
        @Valid final LoginForm loginForm, final BindingResult bindingResult,
        final Model model, final HttpServletRequest request,
        final HttpServletResponse response) throws CMSItemNotFoundException {

        if (somethingMissing) {
            return to login page.
        }

        return FORWARD_PREFIX + "/j_spring_security_check";

    }
}

但现在我收到不支持请求方法的帖子。我不知道为什么..?我该如何纠正这个错误..谢谢

4

1 回答 1

1

你需要把它放在 web.xml

<filter> 
    <filter-name>httpMethodFilter</filter-name> 
    <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>httpMethodFilter</filter-name>
    <servlet-name>yourServlet</servlet-name>
</filter-mapping>
于 2012-10-24T11:50:57.270 回答