From d453b50676d67177fa953568cced940dc1a4f205 Mon Sep 17 00:00:00 2001 From: 20987 <2098777519@qq.com> Date: Tue, 28 Apr 2026 10:20:57 +0800 Subject: [PATCH] =?UTF-8?q?feat(notice):=20=E6=B7=BB=E5=8A=A0=E5=85=AC?= =?UTF-8?q?=E5=91=8A=E7=AE=A1=E7=90=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 创建了公告实体类Notice,包含编号、标题、内容、创建时间和状态字段 - 实现了公告控制器NoticeController,提供添加公告接口 - 开发了公告添加页面addNotice.jsp,支持表单提交功能 - 创建了公告展示页面showNotice.jsp用于显示提交结果 - 配置了Spring MVC路由映射处理公告相关请求 - 实现了公告数据的接收和控制台输出功能 --- .../com/ssm/controller/NoticeController.java | 14 +++++- .../src/com/ssm/entity/Notice.java | 33 +++++++++++++- .../web/WEB-INF/view/showNotice.jsp | 13 ++---- .../web/addNotice.jsp | 45 ++++++++++++++----- 4 files changed, 83 insertions(+), 22 deletions(-) diff --git a/grademanagement-SpringMVCProject/src/com/ssm/controller/NoticeController.java b/grademanagement-SpringMVCProject/src/com/ssm/controller/NoticeController.java index ed5a249..f4654e5 100644 --- a/grademanagement-SpringMVCProject/src/com/ssm/controller/NoticeController.java +++ b/grademanagement-SpringMVCProject/src/com/ssm/controller/NoticeController.java @@ -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"; + } +} \ No newline at end of file diff --git a/grademanagement-SpringMVCProject/src/com/ssm/entity/Notice.java b/grademanagement-SpringMVCProject/src/com/ssm/entity/Notice.java index 7c30f7d..fb2788a 100644 --- a/grademanagement-SpringMVCProject/src/com/ssm/entity/Notice.java +++ b/grademanagement-SpringMVCProject/src/com/ssm/entity/Notice.java @@ -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 + + '}'; + } +} \ No newline at end of file diff --git a/grademanagement-SpringMVCProject/web/WEB-INF/view/showNotice.jsp b/grademanagement-SpringMVCProject/web/WEB-INF/view/showNotice.jsp index a58b51b..6dafe18 100644 --- a/grademanagement-SpringMVCProject/web/WEB-INF/view/showNotice.jsp +++ b/grademanagement-SpringMVCProject/web/WEB-INF/view/showNotice.jsp @@ -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" %>
-