基于SSM的学生信息管理系统java学生信息管理系统java系统mysql数据库课设毕设
1.包含源程序,数据库脚本。代码和数据库脚本都有详细注释。
2.课题设计仅供参考学习使用,可以在此基础上进行扩展完善
开发环境:
Eclipse ,MYSQL,JDK1.8,Tomcat 7
涉及技术点:
MVC模式、SpringMvc、Mybatis、Spring、HTML、JavaScript、CSS、JQUERY、DWR、Ajax等
系统采用Mybatis框架实现ORM对象关系映射,前台JSP实现,后台springMvc映射,使用Spring框架进行整合。适合学习J2EE的一段时间的熟手,代码思路清晰,注解详细,数据库用的是mysql5.1,服务器用的tomcat7,JDK版本1.8. 编程软件Eclispe J2EE版本。是典型MVC架构,并且前后台分离
具体功能这里不再赘述,请下方看系统详细演示图,如果大家有什么疑问或者什么不懂得可以在下方给我留言,或者你有更好的建议等等都可以的,也可以找我和我一起交流沟通,互相学习进步!但是dai。ma。you。chang
java web简单学生信息管理系统
项目描述利用Java以及jsp等技术实现学生信息管理,学生可以自己注册登记,教师进行学生管理,快捷方便合理利用资源。
运行环境
jdk7+tomcat8+mysql+IntelliJ IDEA
项目技术(必填)
jsp+servlet+layui+jquery
<%@page import="java.util.List"%>
<%@page import="cg.student.impl.MajorDaoImpl"%>
<%@page import="cg.student.bean.Major"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
Insert title here
注册信息
package cg.student.servlet;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadBase.FileSizeLimitExceededException;
import org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import cg.student.bean.Student;
import cg.student.dao.StudentDao;
import cg.student.impl.StudentDaoImpl;
/**
* Servlet implementation class StuUpdateServlet
*/
@WebServlet(description = "修改个人信息", urlPatterns = { "/UpdateStuServlet" })
public class UpdateStuServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public UpdateStuServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.getWriter().append("Served at: ").append(request.getContextPath());
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
//创建工厂类
DiskFileItemFactory factory = new DiskFileItemFactory();
//创建请求解析器
ServletFileUpload fileUpload = new ServletFileUpload(factory);
//设置上传单个文件的的大小3M
fileUpload.setFileSizeMax(1024*1024*1);
//设置上传总文件的大小10M
fileUpload.setSizeMax(1024*1024*3);
//设置响应内容的编码
response.setContentType("text/html;charset=utf-8");
try {
//解析请求信息,获取FileItem的集合
List items = fileUpload.parseRequest(request);
//遍历集合
for (FileItem fileItem : items) {
//如果是普通的表单项-------
if(fileItem.isFormField()){
//获取参数名
String fieldName = fileItem.getFieldName();// 即name="name"
//获取参数值
String value = fileItem.getString("utf-8");//获得空间的输入值
System.out.println(fieldName+" = "+value);
//如果是文件表单项------
request.setAttribute(fieldName, value);
}else{
//获取文件名
String fileName = fileItem.getName();
int index=fileName.lastIndexOf("\\");
if(index!=-1) {
fileName=fileName.substring(index+1);
}
//获取上传路径
String realPath = getServletContext().getRealPath("/upload/images");//绝对
String Path=request.getContextPath()+"/upload/images/";//相对
//检查upload文件夹是否存在,如果不存在则创建
File f = new File(realPath);
if(!f.exists()){
f.mkdir();
};
//为避免重名生成一个uuid作为文件名的前缀
String prefix = UUID.randomUUID().toString().replace("-", "");
//将文件写入到服务器中
if(fileName!=null && fileName!="") {
fileName=prefix+"_"+fileName;
String fileAbsPath=realPath+File.separator+prefix+"_"+fileName;
String filePath=Path+prefix+"_"+fileName;
File file=new File(fileAbsPath);
fileItem.write(file);
//fileItem.write(new File(realPath+File.separator+fileName));
request.setAttribute("fileAbsURL", fileAbsPath);
request.setAttribute("fileURL", filePath);
request.setAttribute("fileName", fileName);
}
System.out.println(fileName+" = "+realPath+File.separator+fileName);
//清楚文件缓存
fileItem.delete();
}
}
} catch (Exception e) {
if(e instanceof SizeLimitExceededException){
//文件总大小超出限制
response.getWriter().print("上传文件的总大小不能超过3M");
}else if(e instanceof FileSizeLimitExceededException){
//单个文件大小超出限制
response.getWriter().print("上传单个文件的大小不能超过1M");
}
}
HttpSession session = request.getSession();
//从request中取出我需要处理的值
String stuId=(String)request.getAttribute("stuId");
String stuName=(String)request.getAttribute("stuName");
String stuSex=(String)request.getAttribute("stuSex");
String stuBirthday=(String)request.getAttribute("stuBirthday");
String majorNum=(String)request.getAttribute("major");
String classNum=(String)request.getAttribute("classNum");
String stuTelephone=(String)request.getAttribute("stuTelephone");
String stuEmail=(String)request.getAttribute("stuEmail");
String stuQQ=(String)request.getAttribute("stuQQ");
String stuNote=(String)request.getAttribute("stuNote");
String stuPassword=(String)request.getAttribute("stuPassword");
String fileURL=(String)request.getAttribute("fileURL");
String fileAbsURL=(String)request.getAttribute("fileAbsURL");
String fileName=(String)request.getAttribute("fileName");
//数据库操作方法进行操作
Student stu=new Student();
stu.setStuId(stuId);
stu.setStuName(stuName);
stu.setStuSex(stuSex);
stu.setStuBirthday(stuBirthday);
if(majorNum!=null && majorNum!="") {
stu.setMajorNum(Integer.parseInt(majorNum));
}
if(classNum!=null && classNum!="") {
stu.setClassNum(Integer.parseInt(classNum));
}
stu.setStuTelphone(stuTelephone);
stu.setStuEmail(stuEmail);
stu.setStuQQ(stuQQ);
stu.setStuNote(stuNote);
// if(fileName==null) {
// StudentDao sdao=new StudentDaoImpl();
// Student stu1=sdao.getStuInfoByStuId(stuId);
// if(stu1!=null) {
// stu.setStuImgURL(stu1.getStuImgURL());
// stu.setStuImgAbsURL(stu1.getStuImgAbsURL());
// stu.setStuImgFileName(stu1.getStuImgFileName());
// }
// }else {
stu.setStuImgURL(fileURL);
stu.setStuImgAbsURL(fileAbsURL);
stu.setStuImgFileName(fileName);
stu.setStuPassword(stuPassword);
// }
boolean flag=false;
PrintWriter out=response.getWriter();
StudentDao sd=new StudentDaoImpl();
flag=sd.updateStuInfo(stu);
if(flag) {
Student student=sd.getStuInfoByStuId(stuId);
if(stu!=null) {
session.setAttribute("user", student);
}
out.println("");
response.setHeader("refresh", "2;URL=./student/update_stu.jsp");
}else {
out.println("");
response.setHeader("refresh", "2;URL=./student/update_stu.jsp");
}
}
}