Saurabh Kumar
Saurabh Kumar

Reputation: 16671

POST not supported

I had a loginform previously which looked like following

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

but now i changed the form to looks like following.

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

My controller looks like this now

@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";

    }
}

But now i am getting Request method post not supported. I don't know why..? How can i rectify the mistake.. Thanks

Upvotes: 1

Views: 2377

Answers (1)

Wendel Lima
Wendel Lima

Reputation: 26

You need put this on 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>

Upvotes: 1

Related Questions