- 创建了公告实体类Notice,包含编号、标题、内容、创建时间和状态字段 - 实现了公告控制器NoticeController,提供添加公告接口 - 开发了公告添加页面addNotice.jsp,支持表单提交功能 - 创建了公告展示页面showNotice.jsp用于显示提交结果 - 配置了Spring MVC路由映射处理公告相关请求 - 实现了公告数据的接收和控制台输出功能main
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>
|
||||
Loading…
Reference in new issue