首先道歉要问这个重复的问题,但我对此有很多困惑..
实际上在我的spring Application中有Home.jsp、login.jsp和LoginController.java、LoginForm。(听说 Login.jsp 包含 Home.jsp) Login.jsp:
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<fieldset id="signin_menu">
<form:form action="login/processLogin" modelAttribute="LOGIN">
<label for="username">Username or email</label>
<form:input path="userName" tabindex="4" />
</p>
<p>
<label for="password">Password</label>
<form:password path="password" tabindex="5" />
</p>
<p class="remember">
<input id="signin_submit" value="Sign in" tabindex="6" type="submit">
<form:checkbox path="remember" id="remember" name="remember_me"
value="1" tabindex="7" />
<label for="remember">RememberMe</label>
</p>
</form:form>
</fieldset>
登录表单:
public class LoginForm {
private String userName;
private String password;
private boolean remember;
//Setter and getter}
登录控制器.java
@Controller
@RequestMapping(value="login")
public class LoginController {
@Autowired
private UserService userService;
@Autowired
private SessionData sessionData;
@RequestMapping(value = "processLogin", method = RequestMethod.POST)
public String processLogin(LoginForm loginForm, BindingResult result,
Model model) {
if (userService.authenticateUser(loginForm.getUserName(),
loginForm.getPassword())) {
sessionData.setUser(userService.getUser(loginForm.getUserName()));
}
model.addAttribute(FormType.LOGIN.name(), loginForm);
return "redirect:/home";
}}
当我启动服务器时:http://localhost:8080/EClass/home
单击登录按钮(Login.jsp)并单击Submit
按钮请求转到并重定向到主页时,再次显示 url:http://localhost:8080/EClass/home
所以听说没有 Cookie 可以得到它。如何工作还记得我吗?这种情况的选择..
我真的卡住了这一点..所以请帮助我..