(源代码见仓库:https://gitee.com/jianghao233/course)
代码:
web.xml
course
contextConfigLocation
classpath:beans.xml
org.springframework.web.context.ContextLoaderListener
springmvc
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:springmvc.xml
1
springmvc
/
beans.xml
jdbc.properties
jdbc.user=root
jdbc.password=439901
jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.jdbcUrl=jdbc:mysql://localhost:3306/course
jdbc.initialPoolSize=5
jdbc.maxPoolSize=20
springmvc.xml
SelectionMapper.xml
selid, stuid, courseid, year, term, grade
delete from selection
where selid = #{selid,jdbcType=INTEGER}
insert into selection (selid, stuid, courseid,
year, term, grade)
values (#{selid,jdbcType=INTEGER}, #{stuid,jdbcType=INTEGER}, #{courseid,jdbcType=INTEGER},
#{year,jdbcType=INTEGER}, #{term,jdbcType=CHAR}, #{grade,jdbcType=DOUBLE})
insert into selection
and selid,
stuid,
courseid,
year,
term,
grade,
#{selid,jdbcType=INTEGER},
#{stuid,jdbcType=INTEGER},
#{courseid,jdbcType=INTEGER},
#{year,jdbcType=INTEGER},
#{term,jdbcType=CHAR},
#{grade,jdbcType=DOUBLE},
update selection
stuid = #{stuid,jdbcType=INTEGER},
courseid = #{courseid,jdbcType=INTEGER},
year = #{year,jdbcType=INTEGER},
term = #{term,jdbcType=CHAR},
grade = #{grade,jdbcType=DOUBLE},
where selid = #{selid,jdbcType=INTEGER}
update selection
set stuid = #{stuid,jdbcType=INTEGER},
courseid = #{courseid,jdbcType=INTEGER},
year = #{year,jdbcType=INTEGER},
term = #{term,jdbcType=CHAR},
grade = #{grade,jdbcType=DOUBLE}
where selid = #{selid,jdbcType=INTEGER}
TbAdminMapper.xml
adminid, username, password
delete from tb_admin
where adminid = #{adminid,jdbcType=INTEGER}
insert into tb_admin (adminid, username, password
)
values (#{adminid,jdbcType=INTEGER}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}
)
insert into tb_admin
adminid,
username,
password,
#{adminid,jdbcType=INTEGER},
#{username,jdbcType=VARCHAR},
#{password,jdbcType=VARCHAR},
update tb_admin
username = #{username,jdbcType=VARCHAR},
password = #{password,jdbcType=VARCHAR},
where adminid = #{adminid,jdbcType=INTEGER}
update tb_admin
set username = #{username,jdbcType=VARCHAR},
password = #{password,jdbcType=VARCHAR}
where adminid = #{adminid,jdbcType=INTEGER}
TbClassMapper.xml
classid, classname
delete from tb_class
where classid = #{classid,jdbcType=INTEGER}
insert into tb_class (classid, classname)
values (#{classid,jdbcType=INTEGER}, #{classname,jdbcType=VARCHAR})
insert into tb_class
classid,
classname,
#{classid,jdbcType=INTEGER},
#{classname,jdbcType=VARCHAR},
update tb_class
classname = #{classname,jdbcType=VARCHAR},
where classid = #{classid,jdbcType=INTEGER}
update tb_class
set classname = #{classname,jdbcType=VARCHAR}
where classid = #{classid,jdbcType=INTEGER}
TbStudentMapper.xml
stuid, stunum, stuname, password, classid, picurl
delete from tb_student
where stuid = #{stuid,jdbcType=INTEGER}
insert into tb_student (stuid, stunum, stuname,
password, classid, picurl
)
values (#{stuid,jdbcType=INTEGER}, #{stunum,jdbcType=CHAR}, #{stuname,jdbcType=VARCHAR},
#{password,jdbcType=VARCHAR}, #{classid,jdbcType=INTEGER}, #{picurl,jdbcType=VARCHAR}
)
insert into tb_student
stuid,
stunum,
stuname,
password,
classid,
picurl,
#{stuid,jdbcType=INTEGER},
#{stunum,jdbcType=CHAR},
#{stuname,jdbcType=VARCHAR},
#{password,jdbcType=VARCHAR},
#{classid,jdbcType=INTEGER},
#{picurl,jdbcType=VARCHAR},
update tb_student
stunum = #{stunum,jdbcType=CHAR},
stuname = #{stuname,jdbcType=VARCHAR},
password = #{password,jdbcType=VARCHAR},
classid = #{classid,jdbcType=INTEGER},
picurl = #{picurl,jdbcType=VARCHAR},
where stuid = #{stuid,jdbcType=INTEGER}
update tb_student
set stunum = #{stunum,jdbcType=CHAR},
stuname = #{stuname,jdbcType=VARCHAR},
password = #{password,jdbcType=VARCHAR},
classid = #{classid,jdbcType=INTEGER},
picurl = #{picurl,jdbcType=VARCHAR}
where stuid = #{stuid,jdbcType=INTEGER}
接口:
SelectionMapper.java
package com.neuedu.mapper;
import com.neuedu.po.Selection;
public interface SelectionMapper {
int deleteByPrimaryKey(Integer selid);
int insert(Selection record);
int insertSelective(Selection record);
Selection selectByPrimaryKey(Integer selid);
int updateByPrimaryKeySelective(Selection record);
int updateByPrimaryKey(Selection record);
}
TbAdminMapper.java
package com.neuedu.mapper;
import com.neuedu.po.TbAdmin;
public interface TbAdminMapper {
int deleteByPrimaryKey(Integer adminid);
int insert(TbAdmin record);
int insertSelective(TbAdmin record);
TbAdmin selectByPrimaryKey(Integer adminid);
int updateByPrimaryKeySelective(TbAdmin record);
int updateByPrimaryKey(TbAdmin record);
}
TbClassMapper.java
package com.neuedu.mapper;
import com.neuedu.po.TbClass;
public interface TbClassMapper {
int deleteByPrimaryKey(Integer classid);
int insert(TbClass record);
int insertSelective(TbClass record);
TbClass selectByPrimaryKey(Integer classid);
int updateByPrimaryKeySelective(TbClass record);
int updateByPrimaryKey(TbClass record);
}
TbCourseMapper.java
package com.neuedu.mapper;
import com.neuedu.po.TbCourse;
public interface TbCourseMapper {
int deleteByPrimaryKey(Integer courseid);
int insert(TbCourse record);
int insertSelective(TbCourse record);
TbCourse selectByPrimaryKey(Integer courseid);
int updateByPrimaryKeySelective(TbCourse record);
int updateByPrimaryKey(TbCourse record);
}
TbStudentMapper.java
package com.neuedu.mapper;
import com.neuedu.po.TbStudent;
public interface TbStudentMapper {
int deleteByPrimaryKey(Integer stuid);
int insert(TbStudent record);
int insertSelective(TbStudent record);
TbStudent selectByPrimaryKey(Integer stuid);
int updateByPrimaryKeySelective(TbStudent record);
int updateByPrimaryKey(TbStudent record);
}
AdminService.java
package com.neuedu.service;
public interface AdminService {
public boolean login(String username,String password);
}
Selection.java
package com.neuedu.po;
public class Selection {
private Integer selid;
private Integer stuid;
private Integer courseid;
private Integer year;
private String term;
private Double grade;
public Integer getSelid() {
return selid;
}
public void setSelid(Integer selid) {
this.selid = selid;
}
public Integer getStuid() {
return stuid;
}
public void setStuid(Integer stuid) {
this.stuid = stuid;
}
public Integer getCourseid() {
return courseid;
}
public void setCourseid(Integer courseid) {
this.courseid = courseid;
}
public Integer getYear() {
return year;
}
public void setYear(Integer year) {
this.year = year;
}
public String getTerm() {
return term;
}
public void setTerm(String term) {
this.term = term == null ? null : term.trim();
}
public Double getGrade() {
return grade;
}
public void setGrade(Double grade) {
this.grade = grade;
}
}
TbAdmin.java
package com.neuedu.po;
public class TbAdmin {
private Integer adminid;
private String username;
private String password;
public Integer getAdminid() {
return adminid;
}
public void setAdminid(Integer adminid) {
this.adminid = adminid;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username == null ? null : username.trim();
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password == null ? null : password.trim();
}
}
TbClass.java
package com.neuedu.po;
public class TbClass {
private Integer classid;
private String classname;
public Integer getClassid() {
return classid;
}
public void setClassid(Integer classid) {
this.classid = classid;
}
public String getClassname() {
return classname;
}
public void setClassname(String classname) {
this.classname = classname == null ? null : classname.trim();
}
}
TbCourse.java
package com.neuedu.po;
public class TbCourse {
private Integer courseid;
private String coursename;
private Integer hour;
private Double score;
private String picurl;
public Integer getCourseid() {
return courseid;
}
public void setCourseid(Integer courseid) {
this.courseid = courseid;
}
public String getCoursename() {
return coursename;
}
public void setCoursename(String coursename) {
this.coursename = coursename == null ? null : coursename.trim();
}
public Integer getHour() {
return hour;
}
public void setHour(Integer hour) {
this.hour = hour;
}
public Double getScore() {
return score;
}
public void setScore(Double score) {
this.score = score;
}
public String getPicurl() {
return picurl;
}
public void setPicurl(String picurl) {
this.picurl = picurl == null ? null : picurl.trim();
}
}
TbStudent.java
package com.neuedu.po;
public class TbStudent {
private Integer stuid;
private String stunum;
private String stuname;
private String password;
private Integer classid;
private String picurl;
public Integer getStuid() {
return stuid;
}
public void setStuid(Integer stuid) {
this.stuid = stuid;
}
public String getStunum() {
return stunum;
}
public void setStunum(String stunum) {
this.stunum = stunum == null ? null : stunum.trim();
}
public String getStuname() {
return stuname;
}
public void setStuname(String stuname) {
this.stuname = stuname == null ? null : stuname.trim();
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password == null ? null : password.trim();
}
public Integer getClassid() {
return classid;
}
public void setClassid(Integer classid) {
this.classid = classid;
}
public String getPicurl() {
return picurl;
}
public void setPicurl(String picurl) {
this.picurl = picurl == null ? null : picurl.trim();
}
}
AdminServiceImpl.java
package com.neuedu.service.impl;
import org.springframework.stereotype.Service;
import com.neuedu.service.AdminService;
@Service
public class AdminServiceImpl implements AdminService {
@Override
public boolean login(String username, String password) {
return false;
}
}
login.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
管理员登陆页面
输出: