有一个表单,其中包含一个登录用户的提交
<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>
和相应的控制器方法:
@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:/";
}
出于某种原因,当我点击提交登录按钮时,它总是打开一个新标签,不知道为什么,有人知道吗?
答案 0 :(得分:2)
从target
删除<form>
属性。它指定target window,而不是目标网址。
答案 1 :(得分:2)
删除target="login.do"
。它有一组有限的值:_ blank,_self,_parent,_top,framename。也许你的价值被解释为“_blank”。