Spring-MVC Opening New Tabs For No Apparent Reason
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" />
<label>password:</label>
<input path="password" cssClass="textfield" cssStyle="width:160px;" name="password" type="password" />
<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?
Remove target
attribute from <form>
. It specifies a target window, not a target URL.
Remove target="login.do"
. It has a limited set of values: _blank, _self, _parent, _top, framename. Perhaps your value is interpreted as "_blank".
精彩评论