gpt4 book ai didi

java - Spring-MVC 无缘无故打开新标签

转载 作者:行者123 更新时间:2023-11-29 04:01:51 25 4
gpt4 key购买 nike

有一个表单,其中包含一个用户登录

<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>

和相应的 Controller 方法:

@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:/";
}

出于某种原因,当我点击提交登录按钮时,它总是会打开一个新标签,不知道为什么,有人知道吗?

最佳答案

删除 target来自 <form> 的属性.它指定了一个 target window ,而不是目标网址。

关于java - Spring-MVC 无缘无故打开新标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2975930/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com