用ssm框架写sms项目

在这里插入图片描述
历经一个礼拜的时间在ssm框架的学习和练习中,我逐渐认识和理解了ssm框架
在开发过程中的优势所在。

前两天在理解项目的需求和要求后,按照教案实例的步骤和结合功能需求,
做出来了学生管理项目的雏形。能实现基本功能,但在框架的结构功能还有点
懵懂。接下来一天的项目演示和点评,大脑中对于框架的结构逐步再次深入,
并知晓报错信息的大概原因。第四天做项目的二次重写,再次巩固项目的前前
后后,明显感受到没有了第一次写时的懵懂和陌生。

ssm框架的使用在于之前的web项目对比。原生态的项目同样是采用MVC开发
模式。从model开始,构建实体类,写服务方法,然后用传统jdbc连接模式查找
数据库,每次请求数据库都会重新打开通道,关闭通道。接下来写servlet,接
收页面传输参数–进行业务逻辑处理–储存处理后的值–跳转页面,每实现一个
功能需要创建一个servlet。最后实现view页面渲染,获取servlet储存在session
里面的值,通过el表达式将结果显示在jsp中,最终渲染到浏览器页面。

ssm框架的使用最明显的作用在于,在后台大大简化了代码量。model层通过
@Autowired申明注入对象;dao层的连接数据库通过映射文件注入,通过简单
的sql语句直接操控数据库;servlet层通过RequestMapping和方法名直接取代
了传统的servlet结构,不再是以功能为单位,而是一个需求模块为一个模块的
结构。

在ssm框架的使用中除了框架的构建外,最重要的在于Mapper映射的配置了,
dao层构建接口映射到xml文件操作数据库,数据库查询得结果直接映射成返回
类型的对象,我们只需要构建好对应的属性和字段名。

在这次项目开发过程中,花费时间最长的在配置dao层xml配置文件,时常会报
找不到vlaue,先将预写的sql语句在navicat上测试成功,然后再放置配置文件
中,对应的配置字段根据navicat查询结构一步步对应其column避免重名的错
误。另外在有参数传入的时候忘记在映射表中写入parameter参数也是会报
does not contain value;另一个花费时间长的是找不到页面,打断点输入url不进
入问题,此时要耐性以此查看controller–mapping配置–service–pojo的属性配
置等相关代码,报错的时候也尽量不去用谷歌翻译,直接查看英文报错内容,
一步步去检查。

最后,在实现业务功能的同时,我们要贯彻代码规范的思想,方法名上用文档
注释,类名前注释作者,参数注明作用。着重加强前端js脚本语言实现的灵活
性。往后做项目开发中除了反复多写多练外要学会散发逻辑思维,有一个清晰
的脑回路才能写出简易清晰的代码。

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
package com hmm test820; import java util Scanner; public class SMS { public SMS { } public Student[] stu new Student[10]; public void add Student[] stu Student s { System out println "增加一个学生 " ; System out println Student count ; Student count++; this stu[Student count 1] s; } 删除操作 public void delete Student[] stu String id { int index 0; for int i 0;i<Student count;i++ { if id equals stu[i] id { index i; } } Student count ; System out println Student count ; for int i index;i<Student count;i++ { stu[i] stu[i+1]; } } 修改学生信息 public void update Student[]stu String id String name String age String job { System out println "修改学生信息 " ; for int i 0;i<Student count;i++ { if id equals stu[i] id { this stu[i] name name; this stu[i] age age; this stu[i] job job; } } } 查看单个学生信息 public void query Student[]stu String id { System out println "查看单个学生信息 " ; for int i 0;i<Student count;i++ { if id equals stu[i] id { System out println stu[i] id+" t t"+stu[i] name+" t t"+stu[i] age+" t t"+stu[i] job ; } } } 查看学生信息 public void display Student[]stu { for int i 0;i<Student count;i++ { System out print stu[i] id+" t t"+stu[i] name+" t t"+stu[i] age+" t t"+stu[i] job ; System out println ; } } 界面显示部分 登录界面首页显示 public static void print1 { System out println " n n t t欢迎使用学生信息管理系统2 0版 n" ; System out println " n n" ; System out println " t t t t1 登录系统 n n" ; System out println " t t t t2 退出 n n" ; System out println " n n" ; System out print "请选择 请输入数字:" ; } 成功登录后显示部分 public static void print2 { System out println "欢迎使用学生信息管理系统2 0版" ; System out println " " ; System out println " t t t t1 查看当前学生信息" ; System out println " t t t t2 添加学生信息" ; System out println " t t t t3 修改学生信息" ; System out println " t t t t4 查询学生信息" ; System out println " t t t t5 删除学生信息" ; System out println " t t t t6 退出" ; System out println " " ; } public static void printmessage { System out println "请输入学号 姓名 年龄 职位:" ; } public static void printid { System out println "请输入学号:" ; } public static void printnext { System out print "请继续选择您的操作(输入0返回上一菜单):" ; } public static void printlogin { System out print "请输入登录账号:" ; } public static void printps { System out print "请输入密码:" ; } public static String message { Scanner s new Scanner System in ; String str s next ; return str; } public static void printerror { System out println "input error" ; } public static int inputcount { Scanner s new Scanner System in ; int count s nextInt ; return count; } public static void main String[] args { SMS sms new SMS ; Student s new Student "001" "23" "32" "323" ; boolean flag1 true; while flag1 { print1 ; switch inputcount { case 1: { Student s new Student ; printlogin ; String login message ; printps ; String pw message ; print2 ; if login equals "login" &&pw equals "1" { print2 ; printnext ; boolean flag2 true; while flag2 { switch inputcount { case 1: { sms display sms stu ; printnext ; break; } case 2: { printmessage ; s id message ; s name message ; s age message ; s job message ; s new Student s id s name s age s job ; sms add sms stu s ; printnext ; break; } case 3: { printmessage ; s id message ; s name message ; s age message ; s job message ; s new Student s id s name s age s job ; sms update sms stu s id s name s age s job ; printnext ; break; } case 4: { printid ; s id message ; sms query Student[]stu String id ; printnext ; break; } case 5: { printid ; s id message ; sms delete sms stu s id ; printnext ; break; } case 6: { flag1 false; break; } default: { printerror ; break; } } } } break; } case 2: flag1 false; break; default: printerror ; break; } } } }">package com hmm test820; import java util Scanner; public class SMS { public SMS { } public Student[] stu new Student[10]; public void add Student[] stu Student s { System out println "增加一个学生 " ; System out println Student count ; Student count++; t [更多]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值