81,092
社区成员
发帖
与我相关
我的任务
分享
<%--
Created by IntelliJ IDEA.
User: TeduJAVA
Date: 2019/3/20
Time: 15:53
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<form:form action="/user/login" method="post" modelAttribute="SE_USER">
<input type="text" name="name"><br>
<input type="password" name="password"><br>
<input type="submit" name="登录"><br>
</form:form>
<%--<form action="/user/login" method="post" >--%>
<%--<input type="text" name="name"><br>--%>
<%--<input type="password" name="password"><br>--%>
<%--<input type="submit" name="登录"><br>--%>
<%--</form>--%>
</body>
</html>
package com.sz.controller;
import com.sz.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;
import javax.servlet.http.HttpSession;
@Controller
@RequestMapping("/user")
@SessionAttributes("SE_USER")
public class UserController {
// @RequestMapping("/login")
// public String Login(@ModelAttribute("SE_USER") User user){
// System.out.println("login...");
// return "user";
//}
@RequestMapping("/login")
public String Login(User user, HttpSession session){
System.out.println("login...");
session.setAttribute("SE_USER",user);
return "user";
}
}