标签应该怎么使用,为什么使用后报500,我想使用在form中使用modelAttribute标签可是却提示无法解析,应该怎么使用?

angeltails 2019-03-20 06:22:42



<%--
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";
}
}

...全文
188 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧