views:

24

answers:

2

there is a form with a submit that logs in a user

<div class="logInDIV">
    <form action="login.do" target="login.do" method="post">
        <span style="font-size:77%;">
            <label>email:</label>
            <input path="userName" cssClass="textfield" cssStyle="width:160px;" title="user name" name="userName" type="text" />
            &nbsp;
            <label>password:</label>
            <input path="password" cssClass="textfield" cssStyle="width:160px;" name="password" type="password" />
            &nbsp;
            <input value="Login" class="button" type="submit" style="margin-bottom:4px" />
        </span>
    </form>
</div>

and the corresponding controller method:

@RequestMapping(value = "/login.do", method = RequestMethod.POST)
    public String doLogin(
            @RequestParam(value = "userName") String userName,
            @RequestParam(value = "password") String password,
            HttpSession session) {
        logger.info("login.do : userName=" + userName + ", password=" + password);

        SkunkPostUser skunkPostUser = null;
        try {
            skunkPostUser = profileService.getSkunkPostUser(userName, password);
        } catch (SkunkPostUserNotFoundException userNotFoundException) {
            return "login";
        }
        session.setAttribute("skunkPostUser", skunkPostUser);
        return "redirect:/";
    }

for some reason when I click the submit log in button it always opens a new tab, not sure why, does anyone know?

+2  A: 

Remove target attribute from <form>. It specifies a target window, not a target URL.

axtavt
thanks, I love making HTML errors then blaming it on Spring-MVC :o.
walnutmon
+2  A: 

Remove target="login.do". It has a limited set of values: _blank, _self, _parent, _top, framename. Perhaps your value is interpreted as "_blank".

Bozho