SSM整合之---简单选课系统
简单选课系统
一.实体图
二.功能
三.代码实现
1.SSM环境搭建
(1)pom.xml
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.11</version>
- </dependency>
- <!-- 1.日志 -->
- <!-- 实现slf4j接口并整合 -->
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <version>1.1.1</version>
- </dependency>
- <!-- 2.数据库 -->
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>5.1.37</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>c3p0</groupId>
- <artifactId>c3p0</artifactId>
- <version>0.9.1.2</version>
- </dependency>
- <!-- DAO: MyBatis -->
- <dependency>
- <groupId>org.mybatis</groupId>
- <artifactId>mybatis</artifactId>
- <version>3.3.0</version>
- </dependency>
- <dependency>
- <groupId>org.mybatis</groupId>
- <artifactId>mybatis-spring</artifactId>
- <version>1.2.3</version>
- </dependency>
- <!-- 3.Servlet web -->
- <dependency>
- <groupId>taglibs</groupId>
- <artifactId>standard</artifactId>
- <version>1.1.2</version>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>jstl</artifactId>
- <version>1.2</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- <version>2.5.4</version>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>3.1.0</version>
- </dependency>
- <!-- 4.Spring -->
- <!-- 1)Spring核心 -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- <version>4.1.7.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- <version>4.1.7.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>4.1.7.RELEASE</version>
- </dependency>
- <!-- 2)Spring DAO层 -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-jdbc</artifactId>
- <version>4.1.7.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-tx</artifactId>
- <version>4.1.7.RELEASE</version>
- </dependency>
- <!-- 3)Spring web -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-web</artifactId>
- <version>4.1.7.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-webmvc</artifactId>
- <version>4.1.7.RELEASE</version>
- </dependency>
- <!-- 4)Spring test -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <version>4.1.7.RELEASE</version>
- </dependency>
- <!-- redis客户端:Jedis -->
- <dependency>
- <groupId>redis.clients</groupId>
- <artifactId>jedis</artifactId>
- <version>2.7.3</version>
- </dependency>
- <dependency>
- <groupId>com.dyuproject.protostuff</groupId>
- <artifactId>protostuff-core</artifactId>
- <version>1.0.8</version>
- </dependency>
- <dependency>
- <groupId>com.dyuproject.protostuff</groupId>
- <artifactId>protostuff-runtime</artifactId>
- <version>1.0.8</version>
- </dependency>
- <!-- Map工具类 -->
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- <version>3.2</version>
- </dependency>
- <!-- https://mvnrepository.com/artifact/aopalliance/aopalliance -->
- <dependency>
- <groupId>aopalliance</groupId>
- <artifactId>aopalliance</artifactId>
- <version>1.0</version>
- </dependency>
- <!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver -->
- <dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>aspectjweaver</artifactId>
- <version>1.9.2</version>
- </dependency>
- <!-- https://mvnrepository.com/artifact/org.aspectj/aspectjrt -->
- <dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>aspectjrt</artifactId>
- <version>1.9.3</version>
- </dependency>
- <!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver -->
- <dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>aspectjweaver</artifactId>
- <version>1.9.4</version>
- </dependency>
- </dependencies>
(2)web.xml
- <web-app>
- <display-name>Archetype Created Web Application</display-name>
- <!--配置spring的监听器,默认只加载WEB-INF文件下的applicationContext.xml配置文件-->
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
- <!--设置配置文件的路径-->
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>classpath:applicationContext.xml</param-value>
- </context-param>
- <!--过滤器,处理中文乱码-->
- <filter>
- <filter-name>encodingFilter</filter-name>
- <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
- <init-param>
- <param-name>encoding</param-name>
- <param-value>UTF-8</param-value>
- </init-param>
- <init-param>
- <param-name>forceEncoding</param-name>
- <param-value>true</param-value>
- </init-param>
- </filter>
- <filter-mapping>
- <filter-name>encodingFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- <!--配置前端控制器-->
- <servlet>
- <servlet-name>SpringMVC</servlet-name>
- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
- <init-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>classpath:springmvc.xml</param-value>
- </init-param>
- <!--启动服务器,创建该servlet-->
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>SpringMVC</servlet-name>
- <url-pattern>/</url-pattern>
- </servlet-mapping>
- </web-app>
(3)applicationContext.xml
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:mvc="http://www.springframework.org/schema/mvc"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
- http://www.springframework.org/schema/mvc
- http://www.springframework.org/schema/mvc/spring-mvc.xsd">
- <!--扫描包,只扫描service和dao,controller不需要扫描-->
- <context:component-scan base-package="com.ssm.dao,com.ssm.service"></context:component-scan>
- <!--spring整合Mybatis框架-->
- <!--配置连接池-->
- <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
- <property name="driverClass" value="com.mysql.jdbc.Driver"></property>
- <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/zml03"></property>
- <property name="user" value="root"></property>
- <property name="password" value="root"></property>
- </bean>
- <!--配置SqlSessionFactory工厂-->
- <bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
- <property name="dataSource" ref="dataSource"></property>
- <!--自动扫描UserDao.xml配置文件-->
- <property name="mapperLocations" value="classpath:com/ssm/dao/*.xml"></property>
- </bean>
- <!--配置UserDao接口所在的包-->
- <bean id="mapperScanner" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
- <property name="sqlSessionFactoryBeanName" value="sqlSessionFactoryBean"></property>
- <property name="basePackage" value="com.ssm.dao"></property>
- </bean>
- <!--配置spring框架声明式事务管理-->
- <!--配置事务管理-->
- <bean id="dataSourceTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <property name="dataSource" ref="dataSource"></property>
- </bean>
- <!--配置事务通知-->
- <tx:advice id="txAdvice" transaction-manager="dataSourceTransactionManager">
- <tx:attributes>
- <tx:method name="find*" read-only="true"/>
- <tx:method name="*" isolation="DEFAULT"/>
- </tx:attributes>
- </tx:advice>
- <!-- 配置事务切面 -->
- <!--<aop:config>-->
- <!--<aop:advisor advice-ref="txAdvice" pointcut="execution(* com.ssm.service.Impl.*ServiceImpl.*(..))"></aop:advisor>-->
- <!--</aop:config>-->
- </beans>
(4)springmvc.xml
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:mvc="http://www.springframework.org/schema/mvc"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx.xsd
- http://www.springframework.org/schema/mvc
- http://www.springframework.org/schema/mvc/spring-mvc.xsd
- ">
- <!--开启注解扫描,只扫描controller中的注解-->
- <context:component-scan base-package="com.ssm.controller"></context:component-scan>
- <!--配置视图解析器对象-->
- <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
- <!--配置前缀-->
- <property name="prefix" value="/"></property>
- <!--配置后缀-->
- <property name="suffix" value=".jsp"></property>
- </bean>
- <!--过滤静态资源-->
- <mvc:resources mapping="/css/**" location="/css/"></mvc:resources>
- <mvc:resources mapping="/images/**" location="/images/"></mvc:resources>
- <mvc:resources mapping="/js/**" location="/js/"></mvc:resources>
- <!--开启springmvc注解的支持-->
- <mvc:annotation-driven/>
- <mvc:default-servlet-handler/>
- </beans>
2.entity
(1)Course.java
- package com.ssm.entity;
- public class Course {
- private String cno;
- private String cname;
- private int ctime;
- private int ccredit;
- private String tno;
- public String getCno() {
- return cno;
- }
- public void setCno(String cno) {
- this.cno = cno;
- }
- public String getCname() {
- return cname;
- }
- public void setCname(String cname) {
- this.cname = cname;
- }
- public int getCtime() {
- return ctime;
- }
- public void setCtime(int ctime) {
- this.ctime = ctime;
- }
- public int getCcredit() {
- return ccredit;
- }
- public void setCcredit(int ccredit) {
- this.ccredit = ccredit;
- }
- public String getTno() {
- return tno;
- }
- public void setTno(String tno) {
- this.tno = tno;
- }
- @Override
- public String toString() {
- return "Course{" +
- "cno='" + cno + '\'' +
- ", cname='" + cname + '\'' +
- ", ctime=" + ctime +
- ", ccredit=" + ccredit +
- ", tno='" + tno + '\'' +
- '}';
- }
- }
(2)Dective.java
- package com.ssm.entity;
- public class Dective {
- private int dno;
- private String sno;
- private String cno;
- private double achievement;
- public int getDno() {
- return dno;
- }
- public void setDno(int dno) {
- this.dno = dno;
- }
- public String getSno() {
- return sno;
- }
- public void setSno(String sno) {
- this.sno = sno;
- }
- public String getCno() {
- return cno;
- }
- public void setCno(String cno) {
- this.cno = cno;
- }
- public double getAchievement() {
- return achievement;
- }
- public void setAchievement(double achievement) {
- this.achievement = achievement;
- }
- @Override
- public String toString() {
- return "Dective{" +
- "dno=" + dno +
- ", sno='" + sno + '\'' +
- ", cno='" + cno + '\'' +
- ", achievement=" + achievement +
- '}';
- }
- }
(3)Student.java
- package com.ssm.entity;
- public class Student {
- private String sno;
- private String sname;
- private String ssex;
- private String spassword;
- public String getSno() {
- return sno;
- }
- public void setSno(String sno) {
- this.sno = sno;
- }
- public String getSname() {
- return sname;
- }
- public void setSname(String sname) {
- this.sname = sname;
- }
- public String getSsex() {
- return ssex;
- }
- public void setSsex(String ssex) {
- this.ssex = ssex;
- }
- public String getSpassword() {
- return spassword;
- }
- public void setSpassword(String spassword) {
- this.spassword = spassword;
- }
- @Override
- public String toString() {
- return "Student{" +
- "sno='" + sno + '\'' +
- ", sname='" + sname + '\'' +
- ", ssex='" + ssex + '\'' +
- ", spassword='" + spassword + '\'' +
- '}';
- }
- }
(4)Teacher.java
- package com.ssm.entity;
- public class Teacher {
- private String tno;
- private String tname;
- private String tsex;
- private String tpassword;
- private String ttitle;
- public String getTno() {
- return tno;
- }
- public void setTno(String tno) {
- this.tno = tno;
- }
- public String getTname() {
- return tname;
- }
- public void setTname(String tname) {
- this.tname = tname;
- }
- public String getTsex() {
- return tsex;
- }
- public void setTsex(String tsex) {
- this.tsex = tsex;
- }
- public String getTpassword() {
- return tpassword;
- }
- public void setTpassword(String tpassword) {
- this.tpassword = tpassword;
- }
- public String getTtitle() {
- return ttitle;
- }
- public void setTtitle(String ttitle) {
- this.ttitle = ttitle;
- }
- @Override
- public String toString() {
- return "Teacher{" +
- "tno='" + tno + '\'' +
- ", tname='" + tname + '\'' +
- ", tsex='" + tsex + '\'' +
- ", tpassword='" + tpassword + '\'' +
- ", ttitle='" + ttitle + '\'' +
- '}';
- }
- }
3.dao接口
(1)CourseDao.java
- package com.ssm.dao;
- import com.ssm.entity.Course;
- import com.ssm.view.courseVo;
- import org.mybatis.spring.annotation.MapperScan;
- import org.springframework.stereotype.Repository;
- import java.util.List;
- @Repository
- public interface CourseDao {
- //查询所有课程信息
- public List<Course> selectCourse();
- //查看可选的所有课程
- public List<courseVo> selectAllCourse();
- }
(2)DectiveDao.java
- package com.ssm.dao;
- import com.ssm.entity.Dective;
- import com.ssm.entity.Student;
- import com.ssm.view.DectiveVo;
- import com.ssm.view.StudentVo;
- import com.ssm.view.courseVo;
- import org.apache.ibatis.annotations.Param;
- import org.springframework.stereotype.Repository;
- import java.util.List;
- @Repository
- public interface DectiveDao {
- //插入选课记录
- public void insertDective(Dective dective);
- //学生查询自己的选课记录
- public List<courseVo> selectMy(String sno);
- //删除选课记录
- public void deleteDective(Dective dective);
- //查询成绩
- public List<DectiveVo> selectGrade(String sno);
- //查询选择了某个课程的所有学生信息
- public List<StudentVo> courseStudent(String cname);
- //录入成绩
- public void grade(@Param("sno") String sno,@Param("cno") String cno,@Param("achievement") double achievement);
- }
(3)StudentDao.java
- package com.ssm.dao;
- import com.ssm.entity.Student;
- import org.apache.ibatis.annotations.Param;
- import org.springframework.stereotype.Repository;
- @Repository
- public interface StudentDao {
- //根据sno查找用户的密码,检测登录
- public String selectSpassword(String sno);
- //根据sno查询学生信息
- public Student selectone(String sno);
- //修改学生信息
- public void stuUpdate(@Param("spassword") String spassword,@Param("sno") String sno);
- }
(4)TeacherDao.java
- package com.ssm.dao;
- import com.ssm.entity.Teacher;
- import org.apache.ibatis.annotations.Param;
- import org.springframework.stereotype.Repository;
- import java.util.List;
- @Repository
- public interface TeacherDao {
- //根据tno查找用户的密码,检测登录
- public String selectTpassword(String tno);
- //根据tno查询老师信息
- public Teacher selectte(String tno);
- //修改老师信息
- public void updatete(@Param("tpassword") String tpassword,@Param("tno") String tno);
- //查询某个老师所教的所有课程
- public List<String> selectMyCourse(String tno);
- }
4.dao映射文件
(1)CourseDao.xml
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPEmapper
- PUBLIC"-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.ssm.dao.CourseDao">
- <select id="selectCourse" resultType="com.ssm.entity.Course">
- select * from course
- </select>
- <!--查询课程信息-->
- <select id="selectAllCourse" resultType="com.ssm.view.courseVo">
- select c.*,t.tname from course c,teacher t where c.tno = t.tno
- </select>
- </mapper>
(2)DectiveDao.xml
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPEmapper
- PUBLIC"-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.ssm.dao.DectiveDao">
- <!--插入选课记录-->
- <insert id="insertDective" parameterType="com.ssm.entity.Dective">
- insert into dective(sno,cno) values(#{sno},#{cno})
- </insert>
- <!--删除选课记录-->
- <delete id="deleteDective" parameterType="com.ssm.entity.Dective">
- delete from dective where cno=#{cno} and sno=#{sno}
- </delete>
- <!--学生查询自己的选课记录,包括课程名称和授课教师姓名-->
- <select id="selectMy" parameterType="String" resultType="com.ssm.view.courseVo">
- select c.*,t.tname from dective d LEFT OUTER JOIN course c on d.cno=c.cno LEFT OUTER JOIN teacher t on c.tno=t.tno where d.sno=#{sno}
- </select>
- <!--学生查询成绩-->
- <select id="selectGrade" parameterType="String" resultType="com.ssm.view.DectiveVo">
- select achievement ,c.cname from dective d LEFT OUTER JOIN course c on d.cno=c.cno where sno=#{sno}
- </select>
- <!--查询选择某个课程的所有学生-->
- <select id="courseStudent" parameterType="String" resultType="com.ssm.view.StudentVo">
- select s.* ,c.cno,d.achievement from course c LEFT OUTER JOIN dective d on c.cno=d.cno LEFT OUTER JOIN student s on s.sno=d.sno where c.cname=#{cname}
- </select>
- <!--录入成绩-->
- <update id="grade" parameterType="com.ssm.entity.Dective">
- update dective set achievement=#{achievement} where sno=#{sno} and cno=#{cno}
- </update>
- </mapper>
(3)StudentDao.xml
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPEmapper
- PUBLIC"-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.ssm.dao.StudentDao">
- <!--学生登录-->
- <select id="selectSpassword" resultType="String">
- select spassword from student where sno=#{sno}
- </select>
- <!--根据sno查询学生的信息-->
- <select id="selectone" resultType="com.ssm.entity.Student" parameterType="String">
- select * from student where sno=#{sno}
- </select>
- <!--修改学生信息-->
- <update id="stuUpdate" parameterType="String">
- update student set spassword=#{spassword} where sno=#{sno}
- </update>
- </mapper>
(4)TeacherDao.xml
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPEmapper
- PUBLIC"-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.ssm.dao.TeacherDao">
- <!--老师登录-->
- <select id="selectTpassword" resultType="String">
- select tpassword from teacher where tno=#{tno}
- </select>
- <select id="selectte" parameterType="String" resultType="com.ssm.entity.Teacher">
- select * from teacher where tno=#{tno}
- </select>
- <!--老师修改信息-->
- <update id="updatete" parameterType="String">
- update teacher set tpassword=#{tpassword} where tno=#{tno}
- </update>
- <!--查询老师的所有课程-->
- <select id="selectMyCourse" resultType="String" parameterType="String">
- select cname from course where tno=#{tno}
- </select>
- </mapper>
5.service接口
(1)CourseService.java
- package com.ssm.service;
- import com.ssm.entity.Course;
- import com.ssm.view.courseVo;
- import java.util.List;
- public interface CourseService {
- //查询所有课程信息
- public List<Course> selectCourse();
- //查看可选的所有课程
- public List<courseVo> selectAllCourse();
- }
(2)DectiveService.java
- package com.ssm.service;
- import com.ssm.entity.Dective;
- import com.ssm.entity.Student;
- import com.ssm.view.DectiveVo;
- import com.ssm.view.StudentVo;
- import com.ssm.view.courseVo;
- import org.apache.ibatis.annotations.Param;
- import java.util.List;
- public interface DectiveService {
- //插入选课记录
- public void insertDective(Dective dective);
- //学生查询自己的选课记录
- public List<courseVo> selectMy(String sno);
- //删除选课记录
- public void deleteDective(Dective dective);
- //查询成绩
- public List<DectiveVo> selectGrade(String sno);
- //查询选择了某个课程的所有学生信息
- public List<StudentVo> courseStudent(String cname);
- //录入成绩
- public void grade(String sno, String cno,double achievement);
- }
(3)StudentService.java
- package com.ssm.service;
- import com.ssm.entity.Student;
- public interface StudentService {
- //根据sno查找用户的密码,检测登录
- public String selectSpassword(String sno);
- //根据sno查询学生信息
- public Student selectone(String sno);
- //修改学生信息
- public void stuUpdate(String spassword,String sno);
- }
(4)TeacherService.java
- package com.ssm.service;
- import com.ssm.entity.Teacher;
- import java.util.List;
- public interface TeacherService {
- //根据tno查找用户的密码,检测登录
- public String selectTpassword(String tno);
- //根据tno查询老师信息
- public Teacher selectte(String tno);
- //修改老师信息
- public void updatete(String tpassword,String tno);
- //查询某个老师所教的所有课程
- public List<String> selectMyCourse(String tno);
- }
6.service实现类
(1)CourseServiceImpl.java
- package com.ssm.service.Impl;
- import com.ssm.dao.CourseDao;
- import com.ssm.entity.Course;
- import com.ssm.service.CourseService;
- import com.ssm.view.courseVo;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.List;
- @Service
- public class CourseServiceImpl implements CourseService {
- @Autowired
- private CourseDao courseDao;
- @Override
- public List<Course> selectCourse() {
- return courseDao.selectCourse();
- }
- @Override
- public List<courseVo> selectAllCourse() {
- return courseDao.selectAllCourse();
- }
- }
(2)DectiveServiceImpl.java
- package com.ssm.service.Impl;
- import com.ssm.dao.DectiveDao;
- import com.ssm.entity.Dective;
- import com.ssm.entity.Student;
- import com.ssm.service.DectiveService;
- import com.ssm.view.DectiveVo;
- import com.ssm.view.StudentVo;
- import com.ssm.view.courseVo;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.List;
- @Service
- public class DectiveServiceImpl implements DectiveService {
- @Autowired
- private DectiveDao dectiveDao;
- //插入选课记录
- @Override
- public void insertDective(Dective dective) {
- dectiveDao.insertDective(dective);
- }
- //学生查询自己的选课记录
- @Override
- public List<courseVo> selectMy(String sno) {
- return dectiveDao.selectMy(sno);
- }
- //删除选课记录
- @Override
- public void deleteDective(Dective dective) {
- dectiveDao.deleteDective(dective);
- }
- @Override
- public List<DectiveVo> selectGrade(String sno) {
- return dectiveDao.selectGrade(sno);
- }
- @Override
- public List<StudentVo> courseStudent(String cname) {
- return dectiveDao.courseStudent(cname);
- }
- @Override
- public void grade(String sno, String cno,double achievement) {
- dectiveDao.grade(sno,cno,achievement);
- }
- }
(3)StudentServiceImpl.java
- package com.ssm.service.Impl;
- import com.ssm.dao.StudentDao;
- import com.ssm.entity.Student;
- import com.ssm.service.StudentService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- @Service
- public class StudentServiceImpl implements StudentService {
- @Autowired
- private StudentDao studentDao;
- @Override
- public String selectSpassword(String sno) {
- return studentDao.selectSpassword(sno);
- }
- @Override
- public Student selectone(String sno) {
- return studentDao.selectone(sno);
- }
- @Override
- public void stuUpdate(String spassword,String sno) {
- studentDao.stuUpdate(spassword,sno);
- }
- }
(4)TeacherServiceImpl.java
- package com.ssm.service.Impl;
- import com.ssm.dao.TeacherDao;
- import com.ssm.entity.Teacher;
- import com.ssm.service.TeacherService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.List;
- @Service
- public class TeacherServiceImpl implements TeacherService {
- @Autowired
- private TeacherDao teacherDao;
- @Override
- public String selectTpassword(String tno) {
- return teacherDao.selectTpassword(tno);
- }
- @Override
- public Teacher selectte(String tno) {
- System.out.println(teacherDao.selectte(tno));
- return teacherDao.selectte(tno);
- }
- @Override
- public void updatete(String tpassword, String tno) {
- teacherDao.updatete(tpassword,tno);
- }
- @Override
- public List<String> selectMyCourse(String tno) {
- return teacherDao.selectMyCourse(tno);
- }
- }
7.controller
(1)CourseController.java
- package com.ssm.controller;
- import com.ssm.service.Impl.CourseServiceImpl;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.servlet.ModelAndView;
- @Controller
- @RequestMapping("/courseController")
- public class CourseController {
- @Autowired
- private CourseServiceImpl courseService;
- @RequestMapping("/selectCourse")
- public ModelAndView selectCourse(){
- ModelAndView modelAndView=new ModelAndView();
- modelAndView.addObject("list",courseService.selectCourse());
- modelAndView.setViewName("list");
- return modelAndView;
- }
- //查询所有课程信息
- @RequestMapping("/selectAllCourse")
- public ModelAndView selectAllCourse(){
- ModelAndView modelAndView=new ModelAndView();
- modelAndView.addObject("courseVo",courseService.selectAllCourse());
- modelAndView.setViewName("courseVo");
- return modelAndView;
- }
- //查询所有课程信息
- @RequestMapping("/selectAll")
- public ModelAndView selectAll(){
- ModelAndView modelAndView=new ModelAndView();
- modelAndView.addObject("lookCourse",courseService.selectAllCourse());
- modelAndView.setViewName("lookCourse");
- return modelAndView;
- }
- }
(2)DectiveController.java
- package com.ssm.controller;
- import com.ssm.entity.Dective;
- import com.ssm.service.Impl.DectiveServiceImpl;
- import com.ssm.view.DectiveList;
- import com.ssm.view.DectiveVo;
- import com.ssm.view.StudentVo;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.servlet.ModelAndView;
- import javax.servlet.http.HttpSession;
- import java.util.List;
- @Controller
- @RequestMapping("/dectiveController")
- public class DectiveController {
- @Autowired
- private DectiveServiceImpl dectiveService;
- //插入选课记录
- @RequestMapping("/insertDective")
- public String insertDective(HttpSession httpSession,String cno){
- Dective dective=new Dective();
- dective.setCno(cno);
- dective.setSno((String)httpSession.getAttribute("sno"));
- System.out.println("cno:"+cno+",sno:"+httpSession.getAttribute("sno"));
- dectiveService.insertDective(dective);
- return "redirect:/courseController/selectAllCourse";
- }
- //查询自己选过的课程
- @RequestMapping("/selectMy")
- public ModelAndView selectMy(HttpSession httpSession){
- ModelAndView modelAndView=new ModelAndView();
- modelAndView.addObject("selectMy",dectiveService.selectMy((String)httpSession.getAttribute("sno")));
- modelAndView.setViewName("myDective");
- return modelAndView;
- }
- //删除选课记录
- @RequestMapping("/deleteDective")
- public String deleteDective(HttpSession httpSession,String cno){
- Dective dective=new Dective();
- dective.setCno(cno);
- dective.setSno((String)httpSession.getAttribute("sno"));
- dectiveService.deleteDective(dective);
- return "redirect:selectMy";
- }
- //查询成绩
- @RequestMapping("selectGrade")
- public ModelAndView selectGrade(HttpSession session){
- ModelAndView modelAndView=new ModelAndView();
- List<DectiveVo> list=dectiveService.selectGrade((String)session.getAttribute("sno"));
- System.out.println(list);
- modelAndView.addObject("selectGrade",list);
- modelAndView.setViewName("myGrade");
- return modelAndView;
- }
- //查询选择了某个课程的所有学生信息
- @RequestMapping("/courseStudent")
- public ModelAndView courseStudent(String cname){
- ModelAndView modelAndView=new ModelAndView();
- modelAndView.addObject("student",dectiveService.courseStudent(cname));
- modelAndView.setViewName("courseStudent");
- return modelAndView;
- }
- //查询选择某个课程的所有学生
- @RequestMapping("/courseAllStudent")
- public ModelAndView courseAllStudent(String cname){
- ModelAndView modelAndView=new ModelAndView();
- modelAndView.addObject("studentVo",dectiveService.courseStudent(cname));
- modelAndView.setViewName("grade");
- return modelAndView;
- }
- //录入成绩
- @RequestMapping("/grade")
- public String grade(DectiveList dectiveList){
- System.out.println(dectiveList);
- for(Dective dective:dectiveList.getDectiveList()){
- String sno=dective.getSno();
- String cno=dective.getCno();
- double achievement=dective.getAchievement();
- dectiveService.grade(sno,cno,achievement);
- }
- return "redirect:/teacherController/selectAllCourse";
- }
- }
(3)StudentController.java
- package com.ssm.controller;
- import com.ssm.service.Impl.StudentServiceImpl;
- import org.omg.CORBA.Request;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.http.HttpRequest;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.servlet.ModelAndView;
- import javax.servlet.http.HttpSession;
- @Controller
- @RequestMapping("/studentController")
- public class StudentController {
- @Autowired
- private StudentServiceImpl studentService;
- //检测登录
- @RequestMapping("/selectSpassword")
- public String selectSpassword(HttpSession session, String sno, String password){
- String pwd=studentService.selectSpassword(sno);
- System.out.println(pwd);
- if(pwd.equals(password)){
- session.setAttribute("sno",sno);
- return "redirect:selectone";
- }else{
- return "index";
- }
- }
- //根据sno查询信息
- @RequestMapping("/selectone")
- public ModelAndView selectone(HttpSession session){
- ModelAndView modelAndView=new ModelAndView();
- modelAndView.addObject("student",studentService.selectone((String)session.getAttribute("sno")));
- modelAndView.setViewName("student");
- return modelAndView;
- }
- //根据sno查询信息
- @RequestMapping("/selectstu")
- public ModelAndView selectstu(HttpSession session){
- ModelAndView modelAndView=new ModelAndView();
- modelAndView.addObject("student",studentService.selectone((String)session.getAttribute("sno")));
- modelAndView.setViewName("studentUpdate");
- return modelAndView;
- }
- //修改学生信息
- @RequestMapping("stuUpdate")
- public String stuUpdate(HttpSession session,String spassword){
- System.out.println("密 码: "+spassword);
- studentService.stuUpdate(spassword,(String)session.getAttribute("sno"));
- return "redirect:selectone";
- }
- }
(4)TeacherController.java
- package com.ssm.controller;
- import com.ssm.entity.Teacher;
- import com.ssm.service.Impl.TeacherServiceImpl;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.servlet.ModelAndView;
- import javax.servlet.http.HttpSession;
- @Controller
- @RequestMapping("/teacherController")
- public class TeacherController {
- @Autowired
- private TeacherServiceImpl teacherService;
- //老师登录
- @RequestMapping("/selectTpassword")
- public String selectTpassword(HttpSession session,String tno ,String tpassword){
- String pwd=teacherService.selectTpassword(tno);
- System.out.println(pwd);
- if(pwd.equals(tpassword)){
- session.setAttribute("tno", tno);
- return "redirect:selectte";
- }else{
- return "index";
- }
- }
- //根据tno查询老师信息
- @RequestMapping("/selectte")
- public ModelAndView selectte(HttpSession session){
- ModelAndView modelAndView=new ModelAndView();
- String t=(String)session.getAttribute("tno");
- Teacher te=teacherService.selectte(t);
- modelAndView.addObject("teacher",te);
- System.out.println(te);
- modelAndView.setViewName("teacher");
- return modelAndView;
- }
- @RequestMapping("/selectone")
- public ModelAndView selectone(HttpSession session){
- ModelAndView modelAndView=new ModelAndView();
- String t=(String)session.getAttribute("tno");
- Teacher te=teacherService.selectte(t);
- modelAndView.addObject("teacher",te);
- System.out.println(te);
- modelAndView.setViewName("teacherUpdate");
- return modelAndView;
- }
- //修改老师信息
- @RequestMapping("/updatete")
- public String updatete(HttpSession session,String tpassword){
- teacherService.updatete(tpassword,(String)session.getAttribute("tno"));
- return "redirect:selectte";
- }
- //查询老师的所有课程
- @RequestMapping("/selectMyCourse")
- public ModelAndView selectMyCourse(HttpSession session){
- ModelAndView modelAndView=new ModelAndView();
- modelAndView.addObject("cname",teacherService.selectMyCourse((String)session.getAttribute("tno")));
- modelAndView.setViewName("teacherCourse");
- return modelAndView;
- }
- //查询老师的所有课程
- @RequestMapping("/selectAllCourse")
- public ModelAndView selectAllCourse(HttpSession session){
- ModelAndView modelAndView=new ModelAndView();
- modelAndView.addObject("cname",teacherService.selectMyCourse((String)session.getAttribute("tno")));
- modelAndView.setViewName("courseAll");
- return modelAndView;
- }
- }
8.view
(1)CourseVo.java
- package com.ssm.view;
- public class courseVo {
- private String cno;
- private String cname;
- private int ctime;
- private int tno;
- private String tname;
- public courseVo() {
- }
- public String getCno() {
- return cno;
- }
- public void setCno(String cno) {
- this.cno = cno;
- }
- public String getCname() {
- return cname;
- }
- public void setCname(String cname) {
- this.cname = cname;
- }
- public int getCtime() {
- return ctime;
- }
- public void setCtime(int ctime) {
- this.ctime = ctime;
- }
- public int getTno() {
- return tno;
- }
- public void setTno(int tno) {
- this.tno = tno;
- }
- public String getTname() {
- return tname;
- }
- public void setTname(String tname) {
- this.tname = tname;
- }
- public courseVo(String cno, String cname, int ctime, int tno, String tname) {
- this.cno = cno;
- this.cname = cname;
- this.ctime = ctime;
- this.tno = tno;
- this.tname = tname;
- }
- @Override
- public String toString() {
- return "courseVo{" +
- "cno='" + cno + '\'' +
- ", cname='" + cname + '\'' +
- ", ctime=" + ctime +
- ", tno=" + tno +
- ", tname='" + tname + '\'' +
- '}';
- }
- }
(2)DectiveList.java
- package com.ssm.view;
- import com.ssm.entity.Dective;
- import java.util.List;
- public class DectiveList {
- private List<Dective> dectiveList;
- public List<Dective> getDectiveList() {
- return dectiveList;
- }
- public void setDectiveList(List<Dective> dectiveList) {
- this.dectiveList = dectiveList;
- }
- @Override
- public String toString() {
- return "DectiveList{" +
- "dectiveList=" + dectiveList +
- '}';
- }
- }
(3)DectiveVo.java
- package com.ssm.view;
- public class DectiveVo {
- private String cname;
- private double achievement;
- public String getCname() {
- return cname;
- }
- public void setCname(String cname) {
- this.cname = cname;
- }
- public double getAchievement() {
- return achievement;
- }
- public void setAchievement(double achievement) {
- this.achievement = achievement;
- }
- @Override
- public String toString() {
- return "DectiveVo1{" +
- "cname='" + cname + '\'' +
- ", achievement=" + achievement +
- '}';
- }
- }
(4)StudentVo.java
- package com.ssm.view;
- public class StudentVo {
- private String sno;
- private String sname;
- private String ssex;
- private String spassword;
- private String cno;
- private double achievement;
- public String getSno() {
- return sno;
- }
- public void setSno(String sno) {
- this.sno = sno;
- }
- public String getSname() {
- return sname;
- }
- public void setSname(String sname) {
- this.sname = sname;
- }
- public String getSsex() {
- return ssex;
- }
- public void setSsex(String ssex) {
- this.ssex = ssex;
- }
- public String getSpassword() {
- return spassword;
- }
- public void setSpassword(String spassword) {
- this.spassword = spassword;
- }
- public String getCno() {
- return cno;
- }
- public void setCno(String cno) {
- this.cno = cno;
- }
- public double getAchievement() {
- return achievement;
- }
- public void setAchievement(double achievement) {
- this.achievement = achievement;
- }
- @Override
- public String toString() {
- return "StudentVo{" +
- "sno='" + sno + '\'' +
- ", sname='" + sname + '\'' +
- ", ssex='" + ssex + '\'' +
- ", spassword='" + spassword + '\'' +
- ", cno='" + cno + '\'' +
- ", achievement=" + achievement +
- '}';
- }
- }
9.jsp页面
(1)courseAll.jsp
- <%@ page contentType="text/html;charset=UTF-8" language="java" %>
- <%@page isELIgnored="false" %>
- <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
- <html>
- <head>
- <title>Title</title>
- </head>
- <body>
- <c:forEach items="${cname}" var="name">
- <a href="/dectiveController/courseAllStudent?cname=${name}">${name}</a>
- </c:forEach>
- </body>
- </html>
(2)courseStudent.jsp
- <%@ page contentType="text/html;charset=UTF-8" language="java" %>
- <%@page isELIgnored="false" %>
- <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
- <html>
- <head>
- <title>Title</title>
- </head>
- <body>
- <table>
- <tr>
- <td>学号</td>
- <td>姓名</td>
- </tr>
- <c:forEach items="${student}" var="Student">
- <tr>
- <td>${Student.sno}</td>
- <td>${Student.sname}</td>
- </tr>
- </c:forEach>
- </table>
- </body>
- </html>
(3)courseVo.jsp
- <%@ page contentType="text/html;charset=UTF-8" language="java" %>
- <%@page isELIgnored="false" %>
- <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
- <html>
- <head>
- <title>Title</title>
- </head>
- <body>
- <form>
- <table>
- <tr>
- <td>课程编号</td>
- <td>课程名称</td>
- <td>课时</td>
- <td>教师编号</td>
- <td>教师姓名</td>
- <td></td>
- </tr>
- <c:forEach items="${courseVo}" var="CourseVo">
- <tr>
- <td>${CourseVo.cno}</td>
- <td>${CourseVo.cname}</td>
- <td>${CourseVo.ctime}</td>
- <td>${CourseVo.tno}</td>
- <td>${CourseVo.tname}</td>
- <td><a href="/dectiveController/insertDective?cno=${CourseVo.cno}">选课</a> </td>
- </tr>
- </c:forEach>
- </table>
- </form>
- </body>
- </html>
(4)grade.jsp
- <%@ page contentType="text/html;charset=UTF-8" language="java" %>
- <%@page isELIgnored="false" %>
- <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
- <html>
- <head>
- <title>Title</title>
- </head>
- <body>
- <%! int i=-1; %>
- <form action="/dectiveController/grade" method="post">
- <table>
- <tr>
- <td>课程编号</td>
- <td>学号</td>
- <td>姓名</td>
- <td>成绩</td>
- </tr>
- <c:forEach items="${studentVo}" var="Student">
- <% i=i+1;%>
- <tr>
- <td><input type="text" name="dectiveList[<%=i%>].cno" value="${Student.cno}" readonly="readonly"></td>
- <td><input type="text" name="dectiveList[<%=i%>].sno" value="${Student.sno}" readonly="readonly"></td>
- <td><input type="text" name="sname" value="${Student.sname}" readonly="readonly"></td>
- <td><input type="text" name="dectiveList[<%=i%>].achievement" value="${Student.achievement}" ></td>
- </tr>
- </c:forEach>
- </table>
- <input type="submit">
- </form>
- </body>
- </html>
(5)index.jsp
- <%@ page contentType="text/html;charset=UTF-8" language="java" %>
- <html>
- <head>
- <title>Title</title>
- </head>
- <body>
- 学生<a href="teacherlogin.jsp">老师</a>
- <form action="studentController/selectSpassword" method="post">
- 学号:<input type="text" name="sno">
- 密码:<input type="text" name="password">
- <input type="submit" >
- </form>
- </body>
- </html>
(6)list.jsp
- <%--
- Created by IntelliJ IDEA.
- User: Administrator
- Date: 2019/8/17 0017
- Time: 上午 10:44
- To change this template use File | Settings | File Templates.
- --%>
- <%@ page contentType="text/html;charset=UTF-8" language="java" %>
- <%@page isELIgnored="false" %>
- <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
- <html>
- <head>
- <title>Title</title>
- </head>
- <body>
- ${list}
- <table>
- <c:forEach items="${list2}" var="CourseVo">
- <tr>
- <td>${CourseVo.cno}</td>
- <td>${CourseVo.cname}</td>
- <td>${CourseVo.ctime}</td>
- <td>${CourseVo.tno}</td>
- <td>${CourseVo.tname}</td>
- <td></td>
- </tr>
- </c:forEach>
- </table>
- </body>
- </html>
(7)lookCourse.jsp
- <%@ page contentType="text/html;charset=UTF-8" language="java" %>
- <%@page isELIgnored="false" %>
- <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
- <html>
- <head>
- <title>Title</title>
- </head>
- <body>
- <table>
- <tr>
- <td>课程编号</td>
- <td>课程名称</td>
- <td>课时</td>
- <td>教师编号</td>
- <td>教师姓名</td>
- </tr>
- <c:forEach items="${lookCourse}" var="CourseVo">
- <tr>
- <td>${CourseVo.cno}</td>
- <td>${CourseVo.cname}</td>
- <td>${CourseVo.ctime}</td>
- <td>${CourseVo.tno}</td>
- <td>${CourseVo.tname}</td>
- </tr>
- </c:forEach>
- </table>
- </body>
- </html>
(8)myDective.jsp
- <%@ page contentType="text/html;charset=UTF-8" language="java" %>
- <%@page isELIgnored="false" %>
- <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
- <html>
- <head>
- <title>Title</title>
- </head>
- <body>
- <form>
- <table>
- <tr>
- <td>课程编号</td>
- <td>课程名称</td>
- <td>课时</td>
- <td>教师编号</td>
- <td>教师姓名</td>
- <td></td>
- </tr>
- <c:forEach items="${selectMy}" var="CourseVo">
- <tr>
- <td>${CourseVo.cno}</td>
- <td>${CourseVo.cname}</td>
- <td>${CourseVo.ctime}</td>
- <td>${CourseVo.tno}</td>
- <td>${CourseVo.tname}</td>
- <td><a href="/dectiveController/deleteDective?cno=${CourseVo.cno}">删除</a> </td>
- </tr>
- </c:forEach>
- </table>
- </form>
- </body>
- </html>
(9)myGrade.jsp
- <%@ page contentType="text/html;charset=UTF-8" language="java" %>
- <%@page isELIgnored="false" %>
- <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
- <html>
- <head>
- <title>Title</title>
- </head>
- <body>
- <form>
- <table>
- <tr>
- <td>课程名称</td>
- <td>成绩</td>
- </tr>
- <c:forEach items="${selectGrade}" var="DectiveVo">
- <tr>
- <td>${DectiveVo.cname}</td>
- <td>${DectiveVo.achievement}</td>
- </tr>
- </c:forEach>
- </table>
- </form>
- </body>
- </html>
(10)student.jsp
- <%@ page contentType="text/html;charset=UTF-8" language="java" %>
- <%@page isELIgnored="false" %>
- <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
- <html>
- <head>
- <title>Title</title>
- </head>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>JSP Page</title>
- </head>
- <body>
- <a href="/courseController/selectAllCourse">选课</a><br>
- <a href="/dectiveController/selectMy">查询已选课程</a><br>
- <a href="/dectiveController/selectGrade">查询成绩</a><br>
- <a href="/studentController/selectstu">修改信息</a>
- <table>
- <tr>
- <td>学号</td>
- <td>${student.sno}</td>
- </tr>
- <tr>
- <td>姓名</td>
- <td>${student.sname}</td>
- </tr>
- <tr>
- <td>性别</td>
- <td>${student.ssex}</td>
- </tr>
- <tr>
- <td>密码</td>
- <td>${student.spassword}</td>
- </tr>
- </table>
- </body>
- </html>
(11)studentUpdate.jsp
- <%@page contentType="text/html"%>
- <%@page pageEncoding="UTF-8"%>
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>JSP Page</title>
- </head>
- <body>
- <form action="/studentController/stuUpdate" method="post">
- <table>
- <tr>
- <td>学号</td>
- <td><input type="text" value="${student.sno}" readonly="readonly"></td>
- </tr>
- <tr>
- <td>姓名</td>
- <td><input type="text" value="${student.sname}" readonly="readonly"></td>
- </tr>
- <tr>
- <td>登录密码</td>
- <td><input type="text" name="spassword" value="${student.spassword}"></td>
- </tr>
- </table>
- <input type="submit">
- </form>
- </body>
- </html>
(12)teacher.jsp
- <%@page contentType="text/html"%>
- <%@page pageEncoding="UTF-8"%>
- <%@page isELIgnored="false" %>
- <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>JSP Page</title>
- </head>
- <body>
- <a href="/teacherController/selectone">修改</a><br>
- <a href="/courseController/selectAll">查询课程信息</a></a><br>
- <a href="/teacherController/selectMyCourse">查询学生选课信息</a></a><br>
- <a href="/teacherController/selectAllCourse">录入成绩</a></a><br>
- <table>
- <tr>
- <td>教师编号:</td>
- <td>${teacher.tno}</td>
- </tr>
- <tr>
- <td>教师姓名:</td>
- <td>${teacher.tname}</td>
- </tr>
- <tr>
- <td>登录密码:</td>
- <td>${teacher.tpassword}</td>
- </tr>
- </table>
- </body>
- </html>
(13)teacherCourse.jsp
- <%@ page contentType="text/html;charset=UTF-8" language="java" %>
- <%@page isELIgnored="false" %>
- <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
- <html>
- <head>
- <title>Title</title>
- </head>
- <body>
- <c:forEach items="${cname}" var="name">
- <a href="/dectiveController/courseStudent?cname=${name}">${name}</a>
- </c:forEach>
- </body>
- </html>
(14)teacherlogin.jsp
- <%@page contentType="text/html"%>
- <%@page pageEncoding="UTF-8"%>
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>JSP Page</title>
- </head>
- <body>
- <a href="index.jsp">学生</a>老师
- <form action="teacherController/selectTpassword" method="post">
- 教师编号:<input type="text" name="tno">
- 密码:<input type="text" name="tpassword">
- <input type="submit"/>
- </form>
- </body>
- </html>
(15)teacherUpdate.jsp
- <%@page contentType="text/html"%>
- <%@page pageEncoding="UTF-8"%>
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>JSP Page</title>
- </head>
- <body>
- <form action="/teacherController/updatete" method="post">
- <table>
- <tr>
- <td>教师编号</td>
- <td><input type="text" value="${teacher.tno}" readonly="readonly"></td>
- </tr>
- <tr>
- <td>教师姓名</td>
- <td><input type="text" value="${teacher.tname}" readonly="readonly"></td>
- </tr>
- <tr>
- <td>登录密码</td>
- <td><input type="text" name="tpassword" value="${teacher.tpassword}"></td>
- </tr>
- </table>
- <input type="submit">
- </form>
- </body>
- </html>
- =========================demo21==========================
SSM整合之---简单选课系统的更多相关文章
- SSM整合的简单实现
整合需要的jar包和源码将在文末给出 本文参考黑马程序员视频,由于视频用的环境和我使用的环境不同,建议使用我的环境及jar包(比较新) 一 整合思路 第一步 整合dao层 mybatis和spring ...
- SpringMVC之简单的增删改查示例(SSM整合)
本篇文章主要介绍了SpringMVC之简单的增删改查示例(SSM整合),这个例子是基于SpringMVC+Spring+Mybatis实现的.有兴趣的可以了解一下. 虽然已经在做关于SpringMVC ...
- 一个简单的python选课系统
下面介绍一下自己写的python程序,主要是的知识点为sys.os.json.pickle的模块应用,python程序包的的使用,以及关于类的使用. 下面是我的程序目录: bin是存放一些执行文件co ...
- ssm 整合 redis(简单教程)
最后我建议大家使用 Spring StringRedisTemplate 配置,参阅: http://blog.csdn.net/hanjun0612/article/details/78131333 ...
- Javaweb实现简单的选课系统(主要技术包括jsp、Servlet、Javabean)
一.背景信息: 首先,这个选课系统是上周一老师在课堂上让我们做的测试,考试时长三个小时,我只做了一半,也没有实现选课流程. 由于上周忙于写实验报告没有时间继续完成这个测试.这周用前天和昨天一共七个小时 ...
- SSM + VUE 实现简单的 CRUD
一.项目分析 1.需求 (1)使用 ssm + vue 实现一个crud(数据库增删改查)的简单实现.(2)前后端分离,前端页面展示+后台管理. 2.技术点 (1)基础框架: SSM(Spring,S ...
- 08 SSM整合案例(企业权限管理系统):05.SSM整合案例的基本介绍
04.AdminLTE的基本介绍 05.SSM整合案例的基本介绍 06.产品操作 07.订单操作 08.权限控制 09.用户和角色操作 10.权限关联 11.AOP日志 05.SSM整合案例的基本介绍 ...
- SSM整合以及相关补充
SSM整合以及相关补充 我们在前面已经学习了Maven基本入门,Spring,SpringMVC,MyBatis三件套 现在我们来通过一些简单的案例,将我们最常用的开发三件套整合起来,进行一次完整的项 ...
- Python开发程序:选课系统-改良版
程序名称: 选课系统 角色:学校.学员.课程.讲师要求:1. 创建北京.上海 2 所学校2. 创建linux , python , go 3个课程 , linux\py 在北京开, go 在上海开3. ...
随机推荐
- springboot - 应用实践(2)第一个springboot应用
1.使用maven创建一个快速启动项目 2.引入相关依赖 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:x ...
- Cause: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
Caused by: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org ...
- Zookeeper 和Eureka比较
作为服务注册中心,Eureka比Zookeeper好在哪里著名的CAP理论指出,一个分布式系统不可能同时满足C(一致性).A(可用性)和P(分区容错性).由于分区容错性P在是分布式系统中必须要保证的, ...
- 洛谷 P1306 斐波那契公约数 题解
题面 结论:gcd(F[n],F[m])=F[gcd(n,m)]; F[n]=a和F[n+1]=b F[n+2]=a+b,F[n+3]=a+2b,…F[m]=F[m?n?1]a+F[m?n]b F[n ...
- Python爬虫之简单的爬取百度贴吧数据
首先要使用的第类库有 urllib下的request 以及urllib下的parse 以及 time包 random包 之后我们定义一个名叫BaiduSpider类用来爬取信息 属性有 url: ...
- 【golang】浅析rune数据类型
golang中string底层是通过byte数组实现的.中文字符在unicode下占2个字节,在utf-8编码下占3个字节,而golang默认编码正好是utf-8. golang中还有一个byte数据 ...
- qt在tableview中绘制图片
void ItemModelDeletage::paint(QPainter *painter, const QStyleOptionViewItem &option, const QMode ...
- spring之bean的自动扫描
首先看一段applicationContext.xml中的自动扫描配置 <context:component-scan base-package="org.java.test" ...
- (转) Linux权限管理(基本权限、默认权限)
一.文件基本权限 1-1.基本权限的修改 -rw-r--r-- - 第一个"-"表示文件类型(- 文件,d 目录,l 软链接文件) - rw- r-- ...
- 转载:利用php数组函数进行函数式编程
因为一个BUG, 我在一个摇摇欲坠,几乎碰一下就会散架的项目中某一个角落中发现下面这样一段代码 这段程序与那个BUG有密切的关系. 我来回反复的捉摸这段代码, 发现这段代码实现了两个功能 第一个是在一 ...