feat(notice): 添加公告管理功能

- 创建了公告实体类Notice,包含编号、标题、内容、创建时间和状态字段
- 实现了公告控制器NoticeController,提供添加公告接口
- 开发了公告添加页面addNotice.jsp,支持表单提交功能
- 创建了公告展示页面showNotice.jsp用于显示提交结果
- 配置了Spring MVC路由映射处理公告相关请求
- 实现了公告数据的接收和控制台输出功能
main
20987 2 weeks ago
parent 839f88598d
commit d453b50676

@ -1,4 +1,16 @@
package com.ssm.controller;
import com.ssm.entity.Notice;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/notice")
public class NoticeController {
}
@RequestMapping("/add")
public String addNotice(Notice notice) {
System.out.println("公告信息:" + notice.toString());
return "showNotice";
}
}

@ -1,4 +1,35 @@
package com.ssm.entity;
import java.util.Date;
public class Notice {
}
private Integer nid;
private String title;
private String content;
private Date createTime;
private Integer status; // 0草稿 1发布
public Notice() {}
public Integer getNid() { return nid; }
public void setNid(Integer nid) { this.nid = nid; }
public String getTitle() { return title; }
public void setTitle(String title) { this.title = title; }
public String getContent() { return content; }
public void setContent(String content) { this.content = content; }
public Date getCreateTime() { return createTime; }
public void setCreateTime(Date createTime) { this.createTime = createTime; }
public Integer getStatus() { return status; }
public void setStatus(Integer status) { this.status = status; }
@Override
public String toString() {
return "Notice{" +
"nid=" + nid +
", title='" + title + '\'' +
", content='" + content + '\'' +
", createTime=" + createTime +
", status=" + status +
'}';
}
}

@ -1,16 +1,9 @@
<%--
Created by IntelliJ IDEA.
User: cesar
Date: 2026/4/28
Time: 10:07
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
<title>提交成功</title>
</head>
<body>
<h3>Success! 公告信息已在控制台输出!</h3>
</body>
</html>
</html>

@ -1,16 +1,41 @@
<%--
Created by IntelliJ IDEA.
User: cesar
Date: 2026/4/28
Time: 10:05
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
<title>添加公告</title>
</head>
<body>
<form action="${pageContext.request.contextPath}/notice/add" method="post">
<table border="1" cellpadding="5" cellspacing="0">
<tr>
<td>公告编号:</td>
<td><input type="text" name="nid" placeholder="请输入编号"></td>
</tr>
<tr>
<td>公告标题:</td>
<td><input type="text" name="title" placeholder="请输入标题"></td>
</tr>
<tr>
<td>公告内容:</td>
<td><textarea name="content" rows="5" cols="30" placeholder="请输入内容"></textarea></td>
</tr>
<tr>
<td>创建时间:</td>
<td><input type="text" name="createTime" placeholder="格式yyyy-MM-dd"></td>
</tr>
<tr>
<td>状态:</td>
<td>
<select name="status">
<option value="0">草稿</option>
<option value="1" selected>发布</option>
</select>
</td>
</tr>
<tr>
<td align="right"><input type="reset" value="重置"></td>
<td align="center"><input type="submit" value="添加"></td>
</tr>
</table>
</form>
</body>
</html>
</html>
Loading…
Cancel
Save