博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
第二阶段:高校学生选课系统,重要代码。及编程思想讲解
阅读量:5290 次
发布时间:2019-06-14

本文共 9106 字,大约阅读时间需要 30 分钟。

该系统我采用的是java(Spring+SpringMVC+MyBatis)架构,前端使用的是vuejs。vue负责前端,ssm负责后端,分工明确,思路清晰,维护简单。

为什么我会选择用ssm框架来开发,理由如下:

通过Spring的IOC特性,将对象之间的依赖关系交给了Spring控制,方便解耦,简化了开发,使得代码复用,可维护性大幅度提升

通过Spring的AOP特性,对重复模块进行集中,实现事务,日志,权限的控制,aop提供切面编程,同样的增强了生产力

SpringMVC是使用了MVC设计思想的轻量级web框架,对web层进行解耦,使我的开发更简洁与Spring无缝衔接

数据库的操作(sql)采用xml文件配置,解除了sql和代码的耦合

提供映射标签,支持对象和和数据库orm字段关系的映射,支持对象关系映射标签,支持对象关系的组建,提供了xml标签,支持动态的sql

SSM是WEB应用框架,涵盖整个应用层,我这个项目比较小,用ssm框架开发是最好的,轻量级,速度快,效率高。

这是我创建的基本的ssm框架, 其中Spring 和 mybatis整合,连接数据库,进行Junit测试

虽然我在个程序里小用了jsp, 但是我主要是采用动静分离,单独运用vue技术,我可以配置到服务器,把服务器上的mysql接入到ssm项目中,把服务器域名映射的ip接入到vue项目中,这样来运行整个项目。

配置web.xml文件

 配置的spring-mvc的Servlet就是为了完成SpringMVC+MAVEN的整合

<?xml version="1.0" encoding="UTF-8"?>

CORS
com.thetransactioncompany.cors.CORSFilter
cors.allowOrigin
*
cors.supportedMethods
GET, POST, HEAD, PUT, DELETE
cors.supportedHeaders
Accept, Origin, X-Requested-With, Content-Type, Last-Modified
cors.exposedHeaders
Set-Cookie
cors.supportsCredentials
true
CORS
/*
contextConfigLocation
classpath:spring/spring-application.xml
encode
org.springframework.web.filter.CharacterEncodingFilter
true
encoding
UTF-8
forceEncoding
true
org.springframework.web.util.IntrospectorCleanupListener
encode
/*
org.springframework.web.context.ContextLoaderListener
springmvc
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:spring/spring-servlet.xml
1
true
springmvc
*.html
log4jConfigLocation
classpath:log4j.properties
org.springframework.web.util.Log4jConfigListener
60
COOKIE
然后就是最重要的数据库文件的创建,和本地数据库表的创建
/*  Navicat Premium Data Transfer  Source Server         : 本地  Source Server Type    : MySQL  Source Server Version : 50560  Source Host           : localhost:3306  Source Schema         : ssm  Target Server Type    : MySQL  Target Server Version : 50560  File Encoding         : 65001  Date: 17/04/2019 14:04:25 */ SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; -- ---------------------------- -- Table structure for banji -- ---------------------------- DROP TABLE IF EXISTS `banji`; CREATE TABLE `banji`  (   `bjcode` int(22) NOT NULL AUTO_INCREMENT,   `bjname` varchar(22) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,   `bjgrade` varchar(22) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,   PRIMARY KEY (`bjcode`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ---------------------------- -- Records of banji -- ---------------------------- INSERT INTO `banji` VALUES (1, '五班', '二年级'); INSERT INTO `banji` VALUES (2, '三班', '四年级'); INSERT INTO `banji` VALUES (5, '六班', '五年级'); INSERT INTO `banji` VALUES (6, '七班', '一年级'); -- ---------------------------- -- Table structure for course -- ---------------------------- DROP TABLE IF EXISTS `course`; CREATE TABLE `course`  (   `ID` int(22) NOT NULL,   `CouName` varchar(22) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,   PRIMARY KEY (`ID`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ---------------------------- -- Records of course -- ---------------------------- INSERT INTO `course` VALUES (1, '语文'); INSERT INTO `course` VALUES (2, '数学'); INSERT INTO `course` VALUES (3, '英语'); INSERT INTO `course` VALUES (4, '地理'); INSERT INTO `course` VALUES (5, '政治'); INSERT INTO `course` VALUES (6, '历史'); INSERT INTO `course` VALUES (7, '化学'); INSERT INTO `course` VALUES (8, '物理'); -- ---------------------------- -- Table structure for sc -- ---------------------------- DROP TABLE IF EXISTS `sc`; CREATE TABLE `sc`  (   `Sid` int(22) NULL DEFAULT NULL,   `Cid` int(22) NULL DEFAULT NULL ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ---------------------------- -- Records of sc -- ---------------------------- INSERT INTO `sc` VALUES (2, 2); INSERT INTO `sc` VALUES (8, 1); INSERT INTO `sc` VALUES (8, 2); INSERT INTO `sc` VALUES (8, 5); INSERT INTO `sc` VALUES (8, 6); INSERT INTO `sc` VALUES (2, 3); INSERT INTO `sc` VALUES (2, 5); INSERT INTO `sc` VALUES (4, 5); INSERT INTO `sc` VALUES (4, 6); INSERT INTO `sc` VALUES (4, 3); INSERT INTO `sc` VALUES (4, 2); INSERT INTO `sc` VALUES (4, 1); INSERT INTO `sc` VALUES (4, 8); INSERT INTO `sc` VALUES (6, 2); INSERT INTO `sc` VALUES (6, 3); INSERT INTO `sc` VALUES (6, 1); -- ---------------------------- -- Table structure for student -- ---------------------------- DROP TABLE IF EXISTS `student`; CREATE TABLE `student`  (   `ID` int(22) NOT NULL,   `StuName` varchar(22) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,   `StuAge` int(22) NULL DEFAULT NULL,   `Password` varchar(22) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,   PRIMARY KEY (`ID`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ---------------------------- -- Records of student -- ---------------------------- INSERT INTO `student` VALUES (1, '张三', 66, ''); INSERT INTO `student` VALUES (2, '李四', 77, ''); INSERT INTO `student` VALUES (4, '王五', 25, ''); INSERT INTO `student` VALUES (6, '林冲', 33, ''); INSERT INTO `student` VALUES (7, '宋江', 44, ''); INSERT INTO `student` VALUES (8, '孙悟空', 99, '1343'); -- ---------------------------- -- Table structure for teacher -- ---------------------------- DROP TABLE IF EXISTS `teacher`; CREATE TABLE `teacher`  (   `Teaid` int(22) NOT NULL,   `Teaname` varchar(22) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,   `Teaposition` varchar(22) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,   `cid` int(22) NULL DEFAULT NULL,   PRIMARY KEY (`Teaid`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ---------------------------- -- Table structure for user -- ---------------------------- DROP TABLE IF EXISTS `user`; CREATE TABLE `user`  (   `id` int(11) NOT NULL AUTO_INCREMENT,   `userName` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,   `userAge` int(11) NULL DEFAULT NULL,   `userAddress` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,   PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 36 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ---------------------------- -- Records of user -- ---------------------------- INSERT INTO `user` VALUES (14, 'wangwu', 66, 'shanghai'); INSERT INTO `user` VALUES (15, 'wangwu', 66, 'shanghai'); INSERT INTO `user` VALUES (19, 'wcd', 99, 'asfasf'); INSERT INTO `user` VALUES (20, 'wcd', 99, 'asfasf'); INSERT INTO `user` VALUES (21, 'wcd', 99, 'asfasf'); INSERT INTO `user` VALUES (22, 'wcd', 99, 'asfasf'); INSERT INTO `user` VALUES (23, 'wcd', 99, 'asfasf'); INSERT INTO `user` VALUES (24, 'wcd', 99, 'asfasf'); INSERT INTO `user` VALUES (25, 'wcd', 99, 'asfasf'); INSERT INTO `user` VALUES (26, 'wcd', 99, 'asfasf'); INSERT INTO `user` VALUES (27, 'wcd', 99, 'asfasf'); INSERT INTO `user` VALUES (28, 'wcd', 99, 'asfasf'); INSERT INTO `user` VALUES (29, 'wcd', 99, 'asfasf'); INSERT INTO `user` VALUES (30, 'wcd', 99, 'asfasf'); INSERT INTO `user` VALUES (31, 'wcd', 99, 'asfasf'); INSERT INTO `user` VALUES (32, 'wcd', 99, 'asfasf'); INSERT INTO `user` VALUES (33, 'wcd', 99, 'asfasf'); INSERT INTO `user` VALUES (34, 'wcd', 99, 'asfasf'); INSERT INTO `user` VALUES (35, 'wcd', 99, 'asfasf'); SET FOREIGN_KEY_CHECKS = 1;
 

 

 

 

 

 

 

 

 

 

 

转载于:https://www.cnblogs.com/wdyaoyao/p/10939805.html

你可能感兴趣的文章
html代码标签
查看>>
CSS3的一些笔记
查看>>
let、var、const
查看>>
angular服务使用
查看>>
Python3 实例
查看>>
别人的后缀自动机
查看>>
dp四边形优化
查看>>
别人的回文自动机
查看>>
2019牛客暑期多校训练营(第五场)F maximum clique 1 二分图求最大独立集
查看>>
后缀自动机求endpos集大小
查看>>
伯努利数公式
查看>>
可持久化并查集(草稿)
查看>>
HDU 6619 Horse 斜率优化dp
查看>>
01分数规划
查看>>
visual studio code 中 Java Swing 代码提示不全解决
查看>>
二分查找算法
查看>>
window环境下 恢复odoo数据库备份文件时产生的 Database restore error: Command `psql` not found....
查看>>
Vue中watch的简单应用
查看>>
前端防止url输入地址直接访问页面
查看>>
vue解决刷新时闪烁
查看>>