1、SSM框架介绍
1.1、Spring
Spring是一个开源框架,Spring是于2003 年兴起的一个轻量级的Java 开发框架,Spring使用基本的JavaBean来完成以前只可能由EJB完成的事情。 简单来说,Spring是一个轻量级的控制反转(IoC)和面向切面(AOP)的容器框架。
1.2、SpringMVC
Spring MVC属于SpringFrameWork的后续产品,已经融合在Spring Web Flow里面。Spring MVC 分离了控制器、模型对象、分派器以及处理程序对象的角色,这种分离让它们更容易进行定制。
1.3、MyBatis
MyBatis 本是apache的一个开源项目iBatis, 2010年这个项目由apache software foundation 迁移到了google code,并且改名为MyBatis 。MyBatis是一个基于Java的持久层框架。MyBatis 使用简单的 XML或注解用于配置和原始映射,将接口和 Java 的POJOs(Plain Old Java Objects,普通的 Java对象)映射成数据库中的记录。
2、项目环境
本项目的开发基于maven3.4.0,jetty6.1.26,mysql,eclipse,JDK7等
3、SSM整合步骤(超详细)
首先新建一个maven项目,选择maven-archetype-webapp,一直下一步就好了
本项目功能:模拟添加课程、删除课程、查看课程详情、查看所有课程
项目目录如下:
Java部分
view部分
3.1 配置pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.lin</groupId>
<artifactId>ssm_project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<!-- spring版本号 -->
<spring.version>3.2.8.RELEASE</spring.version>
<!-- log4j日志文件管理包版本 -->
<slf4j.version>1.6.6</slf4j.version>
<log4j.version>1.2.12</log4j.version>
<!-- junit版本号 -->
<junit.version>4.10</junit.version>
<!-- mybatis版本号 -->
<mybatis.version>3.2.1</mybatis.version>
</properties>
<dependencies>
<!-- 添加Spring依赖 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<!--单元测试依赖 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- 日志文件管理包 -->
<!-- log start -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- log end -->
<!--spring单元测试依赖 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<!--mybatis依赖 -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${mybatis.version}</version>
</dependency>
<!-- mybatis/spring包 -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.2.0</version>
</dependency>
<!-- mysql驱动包 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.29</version>
</dependency>
<!-- javaee-api包 注意和项目使用的JDK版本对应 -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<!-- javaee-web-api包 注意和项目使用的JDK版本对应 -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<!-- jstl-->
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<!-- <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId>
<version>9.2.2.v20160723</version> -->
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.26</version>
<configuration>
<webAppConfig>
<contextPath>/</contextPath>
</webAppConfig>
</configuration>
</plugin>
</plugins>
<finalName>springmvcTest</finalName>
</build>
</project>
3.2 配置web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>Archetype Created Web Application</display-name>
<!-- 起始欢迎界面 -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!-- 读取spring配置文件 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:application.xml</param-value>
</context-param>
<!-- 设计路径变量值 -->
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>springmvc.root</param-value>
</context-param>
<!-- Spring字符集过滤器 -->
<filter>
<filter-name>SpringEncodingFilter</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>SpringEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 日志记录 -->
<context-param>
<!-- 日志配置文件路径 -->
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.properties</param-value>
</context-param>
<context-param>
<!-- 日志页面的刷新间隔 -->
<param-name>log4jRefreshInterval</param-name>
<param-value>6000</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- springMVC核心配置 -->
<servlet>
<servlet-name>dispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<!--spingMVC的配置路径 -->
<param-value>classpath:springmvc/spring-mvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- 拦截设置 -->
<servlet-mapping>
<servlet-name>dispatcherServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
3.3 配置 application.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:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- 引入jdbc配置文件 -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:properties/*.properties</value>
<!--要是有多个配置文件,只需在这里继续添加即可 -->
</list>
</property>
</bean>
<!-- 配置数据源 -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<!-- 不使用properties来配置 -->
<!-- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/test" />
<property name="username" value="root" />
<property name="password" value="123456" /> -->
<!-- 使用properties来配置 -->
<property name="driverClassName">
<value>${jdbc_driverClassName}</value>
</property>
<property name="url">
<value>${jdbc_url}</value>
</property>
<property name="username">
<value>${jdbc_username}</value>
</property>
<property name="password">
<value>${jdbc_password}</value>
</property>
</bean>
<!-- 自动扫描了所有的XxxxMapper.xml对应的mapper接口文件,这样就不用一个一个手动配置Mpper的映射了,只要Mapper接口类和Mapper映射文件对应起来就可以了。 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage"
value="com.demo.dao" />
</bean>
<!-- 配置Mybatis的文件 ,mapperLocations配置**Mapper.xml文件位置,configLocation配置mybatis-config文件位置-->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mapperLocations" value="classpath*:com/demo/mapper/**/*.xml"/>
</bean>
<!-- 自动扫描注解的bean -->
<context:component-scan base-package="com.demo.service" />
</beans>
3.4 配置spring-mvc.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
<!-- 扫描controller(controller层注入) -->
<context:component-scan base-package="com.demo.controller"/>
<!--DispatcherServlet启用基于annotation的HandlerMapping -->
<mvc:annotation-driven/>
<!-- 静态资源处理,css,js,imgs -->
<mvc:resources location="/resources/" mapping="/resources/**" />
<!-- 对模型视图添加前后缀 -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/view/" p:suffix=".jsp"/>
</beans>
3.5 配置jdbc.properties
jdbc_driverClassName=com.mysql.jdbc.Driver
jdbc_url=jdbc:mysql://localhost:3306/test
jdbc_username=root
jdbc_password=123456
3.6 配置log4j.properties
log4j.rootLogger=DEBUG,Console,Stdout
#Console
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n
log4j.logger.java.sql.ResultSet=INFO
log4j.logger.org.apache=INFO
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG
log4j.appender.Stdout = org.apache.log4j.DailyRollingFileAppender
log4j.appender.Stdout.File = E://logs/log.log
log4j.appender.Stdout.Append = true
log4j.appender.Stdout.Threshold = DEBUG
log4j.appender.Stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.Stdout.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
4.业务代码编写
model层:Course.java
package com.demo.model;
public class Course {
private Integer id; //课程id
private String cname; //课程名称
private String teacher; //代课老师
private String description; //课程说明
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getCname() {
return cname;
}
public void setCname(String cname) {
this.cname = cname == null ? null : cname.trim();
}
public String getTeacher() {
return teacher;
}
public void setTeacher(String teacher) {
this.teacher = teacher == null ? null : teacher.trim();
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description == null ? null : description.trim();
}
}
Course实体对应的xml:CourseMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.demo.dao.CourseDao" >
<resultMap id="BaseResultMap" type="com.demo.model.Course" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="cname" property="cname" jdbcType="VARCHAR" />
<result column="teacher" property="teacher" jdbcType="VARCHAR" />
<result column="description" property="description" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, cname, teacher, description
</sql>
<!--查看课程 -->
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from t_course
where id = #{id,jdbcType=INTEGER}
</select>
<!--查看课程 列表 -->
<select id="getAllCourse" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_course
</select>
<!--删除课程 -->
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from t_course
where id = #{id,jdbcType=INTEGER}
</delete>
<!-- 插入课程 -->
<insert id="insert" parameterType="com.demo.model.Course" >
insert into t_course (id, cname, teacher,
description)
values (#{id,jdbcType=INTEGER}, #{cname,jdbcType=VARCHAR}, #{teacher,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.demo.model.Course" >
insert into t_course
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="cname != null" >
cname,
</if>
<if test="teacher != null" >
teacher,
</if>
<if test="description != null" >
description,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="cname != null" >
#{cname,jdbcType=VARCHAR},
</if>
<if test="teacher != null" >
#{teacher,jdbcType=VARCHAR},
</if>
<if test="description != null" >
#{description,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.demo.model.Course" >
update t_course
<set >
<if test="cname != null" >
cname = #{cname,jdbcType=VARCHAR},
</if>
<if test="teacher != null" >
teacher = #{teacher,jdbcType=VARCHAR},
</if>
<if test="description != null" >
description = #{description,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.demo.model.Course" >
update t_course
set cname = #{cname,jdbcType=VARCHAR},
teacher = #{teacher,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
Dao层:编写CRUD操作CourseDao.java
package com.demo.dao;
import java.util.List;
import com.demo.model.Course;
public interface CourseDao {
int deleteByPrimaryKey(Integer id);
int insert(Course record);
int insertSelective(Course record);
Course selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(Course record);
int updateByPrimaryKey(Course record);
List<Course> getAllCourse();
}
Service业务接口:CourseService.java
package com.demo.service;
import java.util.List;
import com.lin.model.Course;
public interface CourseService {
/**
* 添加课程
* @param course 要添加的课程信息
* @return
*/
int insert(Course course);
/**
* 删除课程
* @param id
* @return
*/
int deleteByPrimaryKey(Integer id);
/**
* 根据课程号查看课程详情
* @param id 课程号
* @return
*/
Course selectByPrimaryKey(Integer id);
/**
* 查看所有课程
* @return 返回课程列表
*/
List<Course> getAllCourse();
}
service实现: CourseServiceImpl.java
package com.demo.service;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.demo.dao.CourseDao;
import com.demo.model.Course;
@Service
public class CourseServiceImpl implements CourseService {
@Resource
private CourseDao courseDao;
public int insert(Course course) {
return courseDao.insert(course);
}
public int deleteByPrimaryKey(Integer id) {
return courseDao.deleteByPrimaryKey(id);
}
public List<Course> getAllCourse() {
return courseDao.getAllCourse();
}
public Course selectByPrimaryKey(Integer id) {
return courseDao.selectByPrimaryKey(id);
}
}
controller控制层:CourseController.java
package com.demo.controller;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.demo.model.Course;
import com.demo.service.CourseService;
@Controller
@RequestMapping("/course")
public class CourseController {
@Resource
private CourseService courseService;
/**
* 查看所有课程
* @param request
* @param model
* @return
*/
@RequestMapping("/list")
public ModelAndView getAllCourse(HttpServletRequest request,Model model) {
ModelAndView mav = new ModelAndView("course-list");
List<Course> courses = courseService.getAllCourse();
System.out.println(courses);
for(Course cou:courses){
System.out.println(cou.getCname());
}
mav.addObject("courses", courses);
return mav;
}
/**
* 查看课程详情
* @param request
* @param model
* @param id 课程id
* @return
*/
@RequestMapping("/detail")
public ModelAndView getCourseDetail(HttpServletRequest request,Model model,Integer id) {
ModelAndView mav = new ModelAndView("course-detail");
Course course = courseService.selectByPrimaryKey(id);
System.out.println(course);
mav.addObject("course", course);
return mav;
}
/**
* 添加课程
* @param request
* @param model
* @return
*/
@RequestMapping("/add")
public ModelAndView addCourse(HttpServletRequest request,Model model) {
ModelAndView mav = new ModelAndView("course-edit");
return mav;
}
/**
* 保存课程
* @param course 课程信息
* @return
*/
@RequestMapping("/save")
public ModelAndView saveCourse(Course course) {
ModelAndView mav = new ModelAndView("course-list");
courseService.insert(course);
List<Course> courses = courseService.getAllCourse();
mav.addObject("courses", courses);
return mav;
}
/**
* 删除课程
* @param id 课程id
* @return
*/
@RequestMapping("/delete")
public ModelAndView deleteCourse(Integer id) {
courseService.deleteByPrimaryKey(id);
ModelAndView mav = new ModelAndView("course-list");
List<Course> courses = courseService.getAllCourse();
mav.addObject("courses", courses);
return mav;
}
}
5.view层
5.1 course-list.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>所有课程列表</title>
<link href="/resources/css/common.css" rel="stylesheet">
</head>
<div><input class="add-btn" type="button" value="新增"
onclick="addCourse()"></div>
<body>
<div class="grid">
<table class="grid-table">
<thead>
<tr>
<th>课程ID</th>
<th>课程名称</th>
<th>代课老师</th>
<th>课程说明</th>
<th>删除</th>
<th>查看详情</th>
</tr>
</thead>
<tbody>
<c:forEach var="course" items="${courses}">
<%--用EL表达式调用list对象的属性循环输出对象的各个属性值--%>
<tr>
<td>${course.id}</td>
<td>${course.cname}</td>
<td>${course.teacher}</td>
<td>${course.description}</td>
<td><input type="button" value="删除课程"
onclick="deleteCourse('${course.id}')"></td>
<td><input type="button" value="查看详情"
onclick="getCourseDetail('${course.id}')"></td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
<script src="/resources/js/course-list.js" type="text/javascript"></script>
</body>
</html>
course-list.js
function deleteCourse(id){
window.location.href='/course/delete?id='+id;
}
function getCourseDetail(id){
window.location.href='/course/detail?id='+id;
}
function addCourse(){
window.location.href='/course/add';
}
5.2 course-detail.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<body>
<h3>课程详情:</h3>
课程id: ${course.id}<br>
课程名称:${course.cname}<br>
代课老师: ${course.teacher}<br>
课程说明:${course.description}<br>
</body>
</html>
5.3 course-edit.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>新增课程</title>
<link href="/resources/css/common.css" rel="stylesheet">
</head>
<body>
<form action="<%=request.getContextPath()%>/course/save" method="post">
<!-- 课程编号:<input type="text" id="id" name="id"/><br/> -->
课程名称:<input class="input-text" type="text" id="cname" name="cname"/><br/><br/>
代课老师:<input class="input-text" type="text" id="teacher" name="teacher"/><br/><br/>
课程说明:<textarea id="description" class="input-text" name="description" rows="5" cols="25"></textarea><br/>
<input class="add-submit" type="submit" value="提交" />
</form>
</body>
</html>
6.项目部署:
右键项目maven build–jetty:run就可以了,在浏览器输入:**
localhost:8080/course/list
赶紧动手做起来把