OA项目笔记
一、创建项目构架
1、创建一个Maven的web工程
1.1修改编译器版本
UTF-8
10
10
5.0.2.RELEASE
1.2导入依赖
依赖可以直接从Maven中央仓库下载
Spring的五个基本依赖
spring-beans
spring-context
spring-core
spring-expression
spring-jcl
spring-aop
spring-aspects
spring-jdbc
SpringMVC的依赖:
spring-web
spring-webmvc
spring-tx
servlet相关依赖:
javax.servlet-api
javax.servlet-jsp-api
lombok依赖
mybatis-spring
mybatis
druid
mysql-connector-java
javax.servlet
javax.servlet-api
3.1.0
provided
javax.servlet.jsp
javax.servlet.jsp-api
2.3.1
provided
org.projectlombok
lombok
1.18.2
provided
com.alibaba
druid
1.1.12
org.mybatis
mybatis-spring
1.3.2
mysql
mysql-connector-java
5.1.47
org.mybatis
mybatis
3.4.6
org.springframework
spring-aop
${spring.version}
org.springframework
spring-aspects
${spring.version}
org.springframework
spring-jdbc
${spring.version}
org.springframework
spring-beans
${spring.version}
org.springframework
spring-core
${spring.version}
org.springframework
spring-context
${spring.version}
org.springframework
spring-expression
${spring.version}
org.springframework
spring-jcl
${spring.version}
org.springframework
spring-web
${spring.version}
org.springframework
spring-webmvc
${spring.version}
org.springframework
spring-tx
${spring.version}
1.3在pom中注册资源目录
src/main/java
**/*.xml
1.4完善maven的目录结构
- 添加src/main/java目录
- 添加src/main/resources目录
- 将这些目录添加上相应的功能属性
1.5定义mybatis主配置文件
1.6定义Spring配置文件
1.7修改web.xml版本
characterEncoding
org.springframework.web.filter.CharacterEncodingFilter
encoding
utf-8
forceEncoding
true
characterEncoding
/*
springmvc
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:applicationContext.xml
1
springmvc
*.do
1.8修改webapp目录中的资源
- 将系统原型复制到webapp目录
- 将Maven工程中原来自带的index.jsp文件删除
2创建数据库
DROP DATABASE IF EXISTS oa;
CREATE DATABASE oa ;
USE oa ;
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `department`
-- ----------------------------
DROP TABLE IF EXISTS `department`;
CREATE TABLE `department` (
`ID` int(11) NOT NULL,
`depname` varchar(20) DEFAULT NULL,
`pid` int(11) DEFAULT NULL,
`email` varchar(30) DEFAULT NULL,
`phone` varchar(20) DEFAULT NULL,
`content` varchar(200) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of department
-- ----------------------------
-- ----------------------------
-- Table structure for `flow_manage`
-- ----------------------------
DROP TABLE IF EXISTS `flow_manage`;
CREATE TABLE `flow_manage` (
`ID` int(11) NOT NULL,
`uid` int(11) DEFAULT NULL,
`flow_name` varchar(20) DEFAULT NULL,
`flow_uid1` int(11) DEFAULT NULL,
`assess1` char(1) DEFAULT NULL,
`assess_time1` date DEFAULT NULL,
`assess_view1` varchar(50) DEFAULT NULL,
`flow_uid2` int(11) DEFAULT NULL,
`assess2` char(1) DEFAULT NULL,
`assess_view2` varchar(50) DEFAULT NULL,
`assess_time2` date DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of flow_manage
-- ----------------------------
-- ----------------------------
-- Table structure for `meeting`
-- ----------------------------
DROP TABLE IF EXISTS `meeting`;
CREATE TABLE `meeting` (
`ID` int(11) NOT NULL,
`depid` int(11) DEFAULT NULL,
`m_type` int(11) DEFAULT NULL,
`m_name` varchar(20) DEFAULT NULL,
`uid` int(11) DEFAULT NULL,
`start_time` date DEFAULT NULL,
`end_time` date DEFAULT NULL,
`room_id` int(11) DEFAULT NULL,
`all_uid` varchar(20) DEFAULT NULL,
`content` varchar(100) DEFAULT NULL,
`upload` varchar(30) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of meeting
-- ----------------------------
-- ----------------------------
-- Table structure for `meeting_room`
-- ----------------------------
DROP TABLE IF EXISTS `meeting_room`;
CREATE TABLE `meeting_room` (
`ID` int(11) NOT NULL,
`room_name` varchar(20) DEFAULT NULL,
`room_content` varchar(100) DEFAULT NULL,
`room_pic` varchar(30) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of meeting_room
-- ----------------------------
-- ----------------------------
-- Table structure for `meeting_type`
-- ----------------------------
DROP TABLE IF EXISTS `meeting_type`;
CREATE TABLE `meeting_type` (
`ID` int(11) NOT NULL,
`fid` int(11) DEFAULT NULL,
`name` varchar(20) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of meeting_type
-- ----------------------------
-- ----------------------------
-- Table structure for `mess_group`
-- ----------------------------
DROP TABLE IF EXISTS `mess_group`;
CREATE TABLE `mess_group` (
`ID` int(11) NOT NULL,
`g_name` varchar(20) DEFAULT NULL,
`g_content` varchar(50) DEFAULT NULL,
`uid` int(11) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of mess_group
-- ----------------------------
-- ----------------------------
-- Table structure for `message`
-- ----------------------------
DROP TABLE IF EXISTS `message`;
CREATE TABLE `message` (
`ID` int(11) NOT NULL,
`g_id` int(11) DEFAULT NULL,
`name` varchar(20) DEFAULT NULL,
`sex` char(1) DEFAULT NULL,
`phone` varchar(20) DEFAULT NULL,
`MSN` varchar(20) DEFAULT NULL,
`address` varchar(30) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of message
-- ----------------------------
-- ----------------------------
-- Table structure for `newlabel`
-- ----------------------------
DROP TABLE IF EXISTS `newlabel`;
CREATE TABLE `newlabel` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`label_name` varchar(20) DEFAULT NULL,
`label_content` varchar(100) DEFAULT NULL,
`pid` int(11) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of newlabel
-- ----------------------------
INSERT INTO `newlabel` VALUES ('1', '体育新闻', '体育新闻体育新闻体育新闻', null);
INSERT INTO `newlabel` VALUES ('2', '娱乐新闻', '娱乐新闻娱乐新闻娱乐新闻', null);
INSERT INTO `newlabel` VALUES ('3', '时政新闻', '时政新闻时政新闻时政新闻', null);
INSERT INTO `newlabel` VALUES ('4', '国际足球', '国际足球国际足球', '1');
INSERT INTO `newlabel` VALUES ('5', 'CBA', '中国篮球中国篮球', '1');
INSERT INTO `newlabel` VALUES ('6', '武林风', '河南武林风', '1');
INSERT INTO `newlabel` VALUES ('7', '网球', '网球网球', '1');
INSERT INTO `newlabel` VALUES ('8', '羽毛球', '羽毛球羽毛球', '1');
INSERT INTO `newlabel` VALUES ('9', '乒乓球', '乒乓球乒乓球', '1');
INSERT INTO `newlabel` VALUES ('10', '中超联赛', '中超联赛中超联赛', '1');
INSERT INTO `newlabel` VALUES ('11', '体坛名将', '体坛名将体坛名将', '1');
INSERT INTO `newlabel` VALUES ('12', '体坛快讯', '体坛快讯体坛快讯', '1');
INSERT INTO `newlabel` VALUES ('13', '内地影讯', '内地影讯内地影讯', '2');
INSERT INTO `newlabel` VALUES ('14', '内地影星', '内地影星内地影星', '2');
INSERT INTO `newlabel` VALUES ('15', '港台影星', '港台影星港台影星', '2');
INSERT INTO `newlabel` VALUES ('16', '欧美影讯', '欧美影讯欧美影讯', '2');
INSERT INTO `newlabel` VALUES ('17', '日韩影讯', '日韩影讯日韩影讯', '2');
INSERT INTO `newlabel` VALUES ('18', '今日历史', '今日历史今日历史', '3');
INSERT INTO `newlabel` VALUES ('19', '中央要闻', '中央要闻中央要闻', '3');
INSERT INTO `newlabel` VALUES ('20', '地方要闻', '地方要闻地方要闻', '3');
INSERT INTO `newlabel` VALUES ('21', '国际动态', '国际动态国际动态', '3');
-- ----------------------------
-- Table structure for `newmanage`
-- ----------------------------
DROP TABLE IF EXISTS `newmanage`;
CREATE TABLE `newmanage` (
`ID` int(11) NOT NULL,
`uid` int(11) DEFAULT NULL,
`labelid` int(11) DEFAULT NULL,
`title` varchar(20) DEFAULT NULL,
`content` varchar(200) DEFAULT NULL,
`time` date DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of newmanage
-- ----------------------------
-- ----------------------------
-- Table structure for `user_duty`
-- ----------------------------
DROP TABLE IF EXISTS `user_duty`;
CREATE TABLE `user_duty` (
`ID` int(11) NOT NULL,
`tid` int(11) DEFAULT NULL,
`name` varchar(20) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of user_duty
-- ----------------------------
-- ----------------------------
-- Table structure for `users`
-- ----------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`ID` int(11) NOT NULL,
`username` varchar(10) DEFAULT NULL,
`password` varchar(10) DEFAULT NULL,
`nickname` varchar(10) DEFAULT NULL,
`worktime` date DEFAULT NULL,
`sex` char(2) DEFAULT NULL,
`depid` int(11) DEFAULT NULL,
`duty` char(2) DEFAULT NULL,
`email` varchar(20) DEFAULT NULL,
`mobile` varchar(20) DEFAULT NULL,
`homephone` varchar(20) DEFAULT NULL,
`workphone` varchar(20) DEFAULT NULL,
`fax` varchar(20) DEFAULT NULL,
`MSN` varchar(20) DEFAULT NULL,
`birthday` date DEFAULT NULL,
`httpaddress` varchar(30) DEFAULT NULL,
`address` varchar(100) DEFAULT NULL,
`content` varchar(200) DEFAULT NULL,
`logontime` date DEFAULT NULL,
`lastlogontime` date DEFAULT NULL,
`logoncount` int(11) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of users
-- ----------------------------
-- ----------------------------
-- Table structure for `work_help`
-- ----------------------------
DROP TABLE IF EXISTS `work_help`;
CREATE TABLE `work_help` (
`ID` int(11) NOT NULL,
`file` varchar(20) DEFAULT NULL,
`content` varchar(50) DEFAULT NULL,
`uid` int(11) DEFAULT NULL,
`time` date DEFAULT NULL,
`count` int(11) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of work_help
-- ----------------------------
-- ----------------------------
-- Table structure for `workmanage`
-- ----------------------------
DROP TABLE IF EXISTS `workmanage`;
CREATE TABLE `workmanage` (
`ID` int(11) NOT NULL,
`title` varchar(20) DEFAULT NULL,
`content` varchar(300) DEFAULT NULL,
`time` date DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of workmanage
-- ----------------------------
二、处理页面跳转
在web.xml中添加欢迎页面
/html/login.jsp
修改login.htm
- 将
htm扩展名修改为jsp - 在文件头部添加page指令
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
- 修改login.jsp文件第31-35行代码为如下内容
if(name=="admin" && pwd=="admin")
{
location.href="../html/index.htm";
return true;
}
修改index.htm
修改left.htm
修改"栏目管理.htm"
三、完成查询功能
查询功能要点:
- 页码的设置
- 分类查询的页码和所选类别的显示
- 下拉菜单的触发时间onChange
四、完成删除功能
删除后应该还显示删除前的页面:需要传递三个参数:id、pageno、model
添加映射文件
问题:
- 当删除一级栏目时,仅仅删除了一级栏目,子栏目没有删除;应当是一级栏目删除时,采取级联删除,或者不允许删除一级栏目
Ajax、json、jQuery完成删除
-
这些语句无作用的原因是:没有加入MVC的竹注解驱动
级联删除
- 查询出id的所有子栏目
- 删除所有子栏目
- 删除id栏目(父栏目)


子栏目删除的问题
- 当前页有一条信息,删除后,当前页码大于总页数
- 解决办法:

- 当子栏目全部删除时,出现错误(-3,3)
- 解决办法

- 当子栏目全部删除时,即pageno<=0,则不用执行分页操作,显示友好的提示信息

五、完成修改功能
修改前的查询

查询时显示当前所要修改栏目的父栏目信息

