parent
cd71b8ac95
commit
9e4aa88a05
@ -0,0 +1,19 @@
|
|||||||
|
package com.ssm.controller;
|
||||||
|
|
||||||
|
import com.ssm.entity.User;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
//请求处理器
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("nihao")
|
||||||
|
public class UserController {
|
||||||
|
@RequestMapping("User")
|
||||||
|
public ModelAndView test(User user){
|
||||||
|
user.printInfo();
|
||||||
|
System.out.println("用户信息:"+user.toString());
|
||||||
|
ModelAndView mv = new ModelAndView("showUser");
|
||||||
|
mv.addObject("printInfo", user);
|
||||||
|
return mv;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
package com.ssm.entity;
|
||||||
|
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class User {
|
||||||
|
private Integer uid;//用户id
|
||||||
|
private String uname;//用户名称
|
||||||
|
private String unumber;//用户电话
|
||||||
|
private String uaddress;//用户地址
|
||||||
|
@DateTimeFormat(pattern = "yyyy-mm-dd")//用户首次登录日期
|
||||||
|
private Date udate;
|
||||||
|
|
||||||
|
public Integer getUid() {
|
||||||
|
return uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUid(Integer uid) {
|
||||||
|
this.uid = uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUname() {
|
||||||
|
return uname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUname(String uname) {
|
||||||
|
this.uname = uname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnumber() {
|
||||||
|
return unumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnumber(String unumber) {
|
||||||
|
this.unumber = unumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUaddress() {
|
||||||
|
return uaddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUaddress(String uaddress) {
|
||||||
|
this.uaddress = uaddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getUdate() {
|
||||||
|
return udate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUdate(Date udate) {
|
||||||
|
this.udate = udate;
|
||||||
|
}
|
||||||
|
public void printInfo(){
|
||||||
|
System.out.println("用户id="+uid +"\n用户名称="+uname+"\n用户电话="+unumber+"\n用户地址="+uaddress+"\n用户首次登录日期="+udate);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
<%--
|
||||||
|
Created by IntelliJ IDEA.
|
||||||
|
User: 86178
|
||||||
|
Date: 2025/3/31
|
||||||
|
Time: 22:31
|
||||||
|
To change this template use File | Settings | File Templates.
|
||||||
|
--%>
|
||||||
|
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>UserController</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Success!
|
||||||
|
<br>
|
||||||
|
用户id:${printInfo.uid}
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
用户名称:${printInfo.uname}
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
用户电话:${printInfo.unumber}
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
用户地址:${printInfo.uaddress}
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
用户首次登录时间:${printInfo.udate}
|
||||||
|
<br>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,49 @@
|
|||||||
|
<%--
|
||||||
|
Created by IntelliJ IDEA.
|
||||||
|
User: 86178
|
||||||
|
Date: 2025/3/31
|
||||||
|
Time: 22:04
|
||||||
|
To change this template use File | Settings | File Templates.
|
||||||
|
--%>
|
||||||
|
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>添加用户</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<form action="nihao/User" method="post">
|
||||||
|
<tr>
|
||||||
|
<td>用户id</td>
|
||||||
|
<td width="20"></td>
|
||||||
|
<td><input type="text" name="uid" placeholder="请输入用户id"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>用户姓名</td>
|
||||||
|
<td width="20"></td>
|
||||||
|
<td><input type="text" name="uname" placeholder="请输入用户姓名"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>用户号码</td>
|
||||||
|
<td width="20"></td>
|
||||||
|
<td><input type="text" name="unumber" placeholder="请输入用户电话号码"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>用户地址</td>
|
||||||
|
<td width="20"></td>
|
||||||
|
<td><input type="text" name="uaddress" placeholder="请输入用户地址"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>登录日期</td>
|
||||||
|
<td width="20"></td>
|
||||||
|
<td><input type="text" name="udate" placeholder="请输入登陆日期"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="right"><input type="reset" value="重置信息"></td>
|
||||||
|
<td></td>
|
||||||
|
<td align="center">
|
||||||
|
<input type="submit" value="添加">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,13 @@
|
|||||||
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||||
|
pageEncoding="UTF-8"%>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>入门程序</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a href="hello">hello world</a>
|
||||||
|
<a href="addUser.jsp">addUser.jsp</a>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
|
|
||||||
version="4.0">
|
|
||||||
</web-app>
|
|
Loading…
Reference in new issue