搭建ssm框架使用动态sql等方法实现功能
该项目运行效果(其中查询可以单个查询也可以多条件查询,操作里的查询为查询该学生的信息)
- 项目结构
由于jar包过多就不展示了
配置ssm方式不一样
配置web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<!-- 0001 创建 前端处理器 -->
<!-- 设置web应用的上下文参数 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<!--使用spring提供的监听器加载上下文的配置文件 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!--struts2 -- fitler 过滤器 -->
<!--no.1 配置spring mvc 的 前端控制器,拦截所有的 请求 -->
<servlet>
<servlet-name>dispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath: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>
<!--配置成 / 的好处 以后 用 Restful 风格 以后讲 -->
<!-- 添加一個 編碼過濾器 解決亂碼 -->
<filter>
<filter-name>CharacterEncodingFilter</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>forceRequestEncoding</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>forceResponseEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
配置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:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="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/aop
http://www.springframework.org/schema/aop/spring-aop-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-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<!--这里面写 spring的配置文件,主要配置和业务逻辑相关联的-->
<!-- 数据源 , 事务管理控制,等等和业务逻辑相关联的-->
<!--c3p0 连接池-->
<context:property-placeholder location="classpath:dbconfig.properties" ></context:property-placeholder>
<bean id="pooledDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" >
<property name="jdbcUrl" value="${jdbc.jdbcUrl}"></property>
<property name="driverClass" value="${jdbc.driverClass}"></property>
<property name="user" value="${jdbc.user}"></property>
<property name="password" value="${jdbc.password}"></property>
</bean>
<!--配置 mybatis -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean" >
<!--指定mybatis全局配置文件的位置-->
<property name="configLocation" value="classpath:mybatis-config.xml"></property>
<property name="dataSource" ref="pooledDataSource" ></property>
<!-- 指定mybatis,dao 的文件的位置-->
<property name="mapperLocations" value="classpath:com/xiao/dao/*.xml"></property>
</bean>
<!--配置扫描器,将mybatis接口的实现加入到ioc容器中-->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer" >
<property name="basePackage" value="com.xiao.dao"></property>
</bean>
<!--配置事务控制-->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" >
<!--控制住数据源 -->
<property name="dataSource" ref="pooledDataSource" ></property>
</bean>
</beans>
配置dbconfig.properties
//因为我的MySQL版本是8,所以要在数据库名后面加一串代码,版本5不用
jdbc.jdbcUrl=jdbc:mysql:///homework?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false
jdbc.driverClass=com.mysql.cj.jdbc.Driver
jdbc.user=root
jdbc.password=123456
配置mybatis-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!-- 数据库表中 驼峰更改下 比如 xx_yy xxYYY-->
<settings>
<setting name="mapUnderscoreToCamelCase" value="true"/>
</settings>
<typeAliases>
<package name="com.xiao.entity"/>
</typeAliases>
<!--分页插件-->
<plugins>
<plugin interceptor="com.github.pagehelper.PageInterceptor" >
<!--分页参数合理化-->
<property name="reasonable" value="true"></property>
</plugin>
</plugins>
</configuration>
配置spring-mvc.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:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="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/aop
http://www.springframework.org/schema/aop/spring-aop-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-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<!--配置springmvc的文件,包含 网站跳转!的逻辑相关的控制和配置 -->
<!--注解扫描 -->
<context:component-scan
base-package="com.xiao" />
<!--配置视图解析器 -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<!-- 配置springmvc不能处理的请求交给tomcat -->
<mvc:default-servlet-handler/>
<!--配置注解驱动,适用于更高级的注解的功能 -->
<mvc:annotation-driven />
<!-- 对静态资源文件的访问 -->
<!-- <mvc:resources mapping="/img/**" location="/WEB-INF/img/" /> -->
<!-- <mvc:resources mapping="/js/**" location="/WEB-INF/js/" /> -->
<!-- 静态资源配置 -->
<mvc:resources mapping="/res/**" location="/WEB-INF/res/" />
</beans>
com.xiao.controller
// StudentController类 主要是方法
package com.xiao.controller;
import com.xiao.entity.StudentInfo;
import com.xiao.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;
@Controller
public class StudentController {
@Autowired
private StudentService studentService;
public StudentService getStudentService() {
return studentService;
}
public void setStudentService(StudentService studentService) {
this.studentService = studentService;
}
// 全查
@RequestMapping("/findAll")
public String findAll(HttpServletRequest request,Model model){
// 每页显示条数
int pageSize = 5;
// 当前页数
int pageCode = 0;
// 多少条数据
int totalCount = 0;
// 多少页
int totalPageCode = 0;
// 总计多少页
totalCount = studentService.getCount();
if (totalCount%pageSize == 0){
totalPageCode = totalCount/pageSize;
}else {
totalPageCode=totalCount/pageSize+1;
}
// 判断当前页数,第一次访问时没有向servlet传递页数,显示第一页
if (request.getParameter("pageCode")==""||request.getParameter("pageCode")==null){
pageCode=1;
}else {
// 不是第一次访问,不能超过总页数
if (Integer.parseInt(request.getParameter("pageCode"))>totalPageCode){
pageCode=totalPageCode;
}else {
// 小于等于总页数
pageCode = Integer.parseInt(request.getParameter("pageCode"));
}
}
// 页数存储到request作用域中
request.setAttribute("pageCode",pageCode);
// 查询所有数据
List<StudentInfo> all = studentService.findAll((pageCode - 1) * pageSize, pageSize);
request.setAttribute("all",all);
request.setAttribute("totalPageCode",totalPageCode);
if (all!=null){
return "show";
}
return "error";
}
// 添加
@RequestMapping("/addStu")
public String insertStu(StudentInfo studentInfo){
int i = studentService.insertStu(studentInfo);
if (i==1){
return "redirect:findAll";
}else {
return "error";
}
}
// 删除
@RequestMapping("/deleteStu")
public String deleteStu(Integer sid){
int i = studentService.deleteStu(sid);
if (i==1){
return "redirect:findAll";
}else {
return "error";
}
}
// 查询单个学生--------查询
@RequestMapping("/findOneId")
public ModelAndView findOneId(ModelAndView modelAndView,Integer sid){
StudentInfo oneStuById = studentService.findOneStuById(sid);
modelAndView.addObject("all",oneStuById);
modelAndView.setViewName("findOne");
return modelAndView;
}
// 查询单个学生--------修改
@RequestMapping("/findOneStuById")
public String findOneStuById(Integer sid,Model model){
StudentInfo oneStuById = studentService.findOneStuById(sid);
model.addAttribute("all",oneStuById);
return "updateStu";
}
// 修改
@RequestMapping("/updateStu")
public String updateStu(StudentInfo stuid){
int i = studentService.updateStu(stuid);
if (i==1){
return "redirect:findAll";
}else {
return "error";
}
}
// 模糊查询
@RequestMapping("/findStuByName")
public String findStuByName(String name,String age,String sex,String id,Model model){
if (Integer.parseInt(id)==0){
id=null;
}
List<StudentInfo> stuByAgeNameSex = studentService.findStuByAgeNameSex(name, age,sex, id);
model.addAttribute("all",stuByAgeNameSex);
return "show";
}
// 查询总条数
@RequestMapping("/getCount")
public int getCount(Model model){
int count = studentService.getCount();
model.addAttribute("count",count);
return count;
}
}
--------------------------------------------------------------------------------------
//PageController 类 主要查找jsp页面
package com.xiao.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class PageController {
@RequestMapping("/add")
public String add(){
return "add";
}
@RequestMapping("/findOne")
public String findOne(){
return "findOne";
}
@RequestMapping("/show")
public String show(){
return "show";
}
}
-
com.xiao.dao
//StudentMapper接口 定义方法
package com.xiao.dao;
import com.xiao.entity.StudentInfo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface StudentMapper {
// 查询所有的学生
public List<StudentInfo> findAll(@Param("pageSize") int pageSize,@Param("pageCode")int pageCode);
// 查询某个学生信息
public StudentInfo findOneStuById(Integer sid);
// 根据学生年龄、姓名、性别、年龄查询学生信息
public List<StudentInfo> findStuByAgeNameSex(@Param("name") String name, @Param("age") String age, @Param("sex") String sex,@Param("id") String id);
// 修改某个学生信息
public int updateStu(StudentInfo stuid);
// 添加某个学生信息
public int insertStu(StudentInfo stuid);
// 删除某个学生信息
public int deleteStu(Integer sid);
// 查询总条数
public int getCount();
}
--------------------------------------------------------------------------------
// StudentMapper.xml 用于写sql(动态sql)
<?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.xiao.dao.StudentMapper">
<resultMap id="studentlist" type="StudentInfo">
<result property="sid" column="sid"/>
<result property="sname" column="sname"/>
<result property="ssex" column="ssex"/>
<result property="sage" column="sage"/>
<result property="scid" column="scid"/>
<association property="classInfo" javaType="ClassInfo" resultMap="class"></association>
</resultMap>
<resultMap id="class" type="ClassInfo">
<result property="cid" column="cid"/>
<result property="cname" column="cname"/>
</resultMap>
<!--查询所有的学生-->
<select id="findAll" resultMap="studentlist" >
SELECT student.*,class.cname FROM student ,class WHERE student.scid= class.cid limit #{pageSize},#{pageCode}
</select>
<!--查询某个学生信息-->
<select id="findOneStuById" parameterType="Integer" resultType="StudentInfo">
SELECT * FROM student where sid=#{sid}
</select>
<!--根据学生年龄、姓名、性别、年龄查询学生信息-->
<select id="findStuByAgeNameSex" resultMap="studentlist">
SELECT student.*,class.cname FROM student ,class WHERE student.scid= class.cid
<if test="name!=null and name !='' ">
and sname LIKE concat('%',concat(#{name},'%'))
</if>
<if test="age!=null and age !='' ">
AND sage=#{age}
</if>
<if test="sex!=null and sex !='' ">
AND ssex=#{sex}
</if>
<if test="id!='' and id!=null">
AND scid=#{id}
</if>
</select>
<!--修改某个学生信息-->
<update id="updateStu" parameterType="String">
UPDATE student
<set>
<if test="sname!=null and sname!=''"> sname=#{sname},</if>
<if test="sage!=null and sage!=''"> sage=#{sage},</if>
<if test="scid!=null and scid!=''"> scid=#{scid},</if>
<if test="ssex!=null and ssex!=''"> ssex=#{ssex}</if>
<!-- where 和if在这里用法效果一样-->
<!--<if test="sid!=null and sid!=''"> where sid=#{sid}</if>-->
<where>
<if test="sid!=null and sid!=''">sid=#{sid}</if>
</where>
</set>
</update>
<!--添加某个学生信息-->
<insert id="insertStu" parameterType="StudentInfo">
INSERT INTO student VALUES (NULL,#{sname},#{ssex},#{sage},#{scid})
</insert>
<!--删除某个学生信息-->
<delete id="deleteStu" parameterType="Integer">
DELETE FROM student WHERE sid=#{sid}
</delete>
<!--查询总条数-->
<select id="getCount" resultType="Integer">
SELECT count(*) FROM student ,class WHERE student.scid= class.cid
</select>
</mapper>
-
com.xiao.entity
//ClassInfo实体类 对应class表里的字段
package com.xiao.entity;
import java.util.List;
public class ClassInfo {
private int cid;
private String cname;
private List<StudentInfo> studentInfos;
public ClassInfo(int cid, String cname, List<StudentInfo> studentInfos) {
this.cid = cid;
this.cname = cname;
this.studentInfos = studentInfos;
}
public ClassInfo(String cname, List<StudentInfo> studentInfos) {
this.cname = cname;
this.studentInfos = studentInfos;
}
public ClassInfo() {
}
public int getCid() {
return cid;
}
public void setCid(int cid) {
this.cid = cid;
}
public String getCname() {
return cname;
}
public void setCname(String cname) {
this.cname = cname;
}
public List<StudentInfo> getStudentInfos() {
return studentInfos;
}
public void setStudentInfos(List<StudentInfo> studentInfos) {
this.studentInfos = studentInfos;
}
@Override
public String toString() {
return "ClassInfo{" +
"cid=" + cid +
", cname='" + cname + '\'' +
", studentInfos=" + studentInfos +
'}';
}
}
-----------------------------------------------------------------------------------
//StudentInfo实体类 对应Student表里的字段
package com.xiao.entity;
public class StudentInfo {
private int sid;
private String sname;
private String ssex;
private String sage;
private int scid;
private ClassInfo classInfo;
public StudentInfo(int sid, String sname, String ssex, String sage, int scid, ClassInfo classInfo) {
this.sid = sid;
this.sname = sname;
this.ssex = ssex;
this.sage = sage;
this.scid = scid;
this.classInfo = classInfo;
}
public StudentInfo(String sname, String ssex, String sage, int scid, ClassInfo classInfo) {
this.sname = sname;
this.ssex = ssex;
this.sage = sage;
this.scid = scid;
this.classInfo = classInfo;
}
public StudentInfo(String sname, String ssex, String sage, int scid) {
this.sname = sname;
this.ssex = ssex;
this.sage = sage;
this.scid = scid;
}
public StudentInfo() {
}
public int getSid() {
return sid;
}
public void setSid(int sid) {
this.sid = sid;
}
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 getSage() {
return sage;
}
public void setSage(String sage) {
this.sage = sage;
}
public int getScid() {
return scid;
}
public void setScid(int scid) {
this.scid = scid;
}
public ClassInfo getClassInfo() {
return classInfo;
}
public void setClassInfo(ClassInfo classInfo) {
this.classInfo = classInfo;
}
@Override
public String toString() {
return "StudentInfo{" +
"sid=" + sid +
", sname='" + sname + '\'' +
", ssex='" + ssex + '\'' +
", sage='" + sage + '\'' +
", scid=" + scid +
", classInfo=" + classInfo +
'}';
}
}
-
com.xiao.service
// StudentService 使dao包里的Controller调用
package com.xiao.service;
import com.xiao.dao.StudentMapper;
import com.xiao.entity.StudentInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class StudentService {
@Autowired
private StudentMapper studentMapper;
// 全查方法
public List<StudentInfo> findAll(int pageSize,int pageCode){
return studentMapper.findAll(pageSize,pageCode);
}
// 添加
public int insertStu(StudentInfo stuid){
return studentMapper.insertStu(stuid);
}
// 删除某个学生信息
public int deleteStu(Integer sid){
return studentMapper.deleteStu(sid);
}
// 查询某个学生
public StudentInfo findOneStuById(Integer sid){
return studentMapper.findOneStuById(sid);
}
// 修改某个学生信息
public int updateStu(StudentInfo stuid){
return studentMapper.updateStu(stuid);
}
// 根据学生年龄、姓名、性别、年龄查询学生信息
public List<StudentInfo> findStuByAgeNameSex(String name, String age, String sex, String id){
return studentMapper.findStuByAgeNameSex(name, age, sex,id);
}
// 查询总条数
public int getCount(){
return studentMapper.getCount();
}
}
- jsp页面
add.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>添加页面</title>
</head>
<body>
<form action="/addStu" method="post">
学生姓名:<input type="text" name="sname"/> <br>
学生性别:<input type="radio" name="ssex" value="男"/>男
<input type="radio" name="ssex" value="女"/>女 <br>
学生年龄:<input type="text" name="sage"/> <br>
班级编号:<select name="scid">
<option value="1">1001</option>
<option value="2">1002</option>
<option value="3">1003</option>
<option value="4">1004</option>
<option value="5">1005</option>
<option value="6">1006</option>
</select> <br>
<input type="submit" value="提交">
</form>
</body>
</html>
----------------------------------------------------------------------------------------
error.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>错误</title>
</head>
<body>
<h1>错误</h1>
</body>
</html>
----------------------------------------------------------------------------------------
findOne.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>查单</title>
</head>
<body>
<form action="/findOneStuById" method="post">
学生编号: <input type="text" name="sid" value="${all.sid}"/><br>
学生姓名:<input type="text" name="sname" value="${all.sname}"/> <br>
学生性别:<input type="text" name="ssex" value="${all.ssex}"/> <br>
学生年龄:<input type="text" name="sage" value="${all.sage}"/> <br>
班级编号:<input type="text" name="scid" value="${all.scid}"/> <br>
<a href="/findAll">退出</a>
</form>
</body>
</html>
----------------------------------------------------------------------------------------
show.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>展示界面</title>
</head>
<body>
<div align="center">
<form action="/findStuByName" method="post">
<table>
<tr>
<td>根据学生姓名查询:</td>
<td><input type="text" name="name"/></td>
</tr>
<tr>
<td>根据学生年龄查询:</td>
<td>
<input type="text" name="age"/>
</td>
</tr>
<tr>
<td>根据学生性别查询:</td>
<td>
<input type="radio" name="sex" value="男"/>男
<input type="radio" name="sex" value="女"/>女
</td>
</tr>
<tr>
<td> 根据班级编号查询:</td>
<td>
<select name="id">
<option value="0">请选择班级</option>
<option value="1">1001</option>
<option value="2">1002</option>
<option value="3">1003</option>
<option value="4">1004</option>
<option value="5">1005</option>
<option value="6">1006</option>
</select>
<input type="submit" value="搜索"/>
</td>
</tr>
</table>
</form>
</div>
<table align="center" border="1px" cellpadding="0px">
<tr>
<td>学生编号</td>
<td>学生姓名</td>
<td>学生性别</td>
<td>学生年龄</td>
<td>班级编号</td>
<td>班级名称</td>
<td align="center">操作</td>
</tr>
<c:forEach items="${all}" var="s">
<tr>
<td>${s.sid}</td>
<td>${s.sname}</td>
<td>${s.ssex}</td>
<td>${s.sage}</td>
<td>${s.scid}</td>
<td>${s.classInfo.cname}</td>
<td>
<a href="deleteStu?sid=${s.sid}" >删除</a>
||
<a href="findOneStuById?sid=${s.sid}">修改</a>
||
<a href="/add">新增</a>
||
<a href="/findOneId?sid=${s.sid}">查询</a>
</td>
</tr>
</c:forEach>
<tr>
<td><a href="findAll?pageCode=1">首页</a></td>
<c:if test="${pageCode==1}" var="flag"></c:if>
<c:if test="${flag}">
<td><a href="findAll?pageCode=${1}">上一页</a></td>
</c:if>
<c:if test="${!flag}">
<td><a href="findAll?pageCode=${pageCode-1}">上一页</a></td>
</c:if>
<td>当前第${pageCode}页</td>
<td>共${totalPageCode}页</td>
<td><a href="findAll?pageCode=${pageCode+1}">下一页</a></td>
<td><a href="findAll?pageCode=${totalPageCode}">尾页</a></td>
</tr>
</table>
</body>
</html>
--------------------------------------------------------------------------------------
updateStu.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>修改</title>
</head>
<body>
<form action="/updateStu" method="post">
<input type="hidden" name="sid" value="${all.sid}"/>
学生姓名:<input type="text" name="sname" value="${all.sname}"/> <br>
学生性别:<input type="radio" name="ssex" value="男" <c:if test="${all.ssex=='男'}">checked="checked"</c:if>>男
<input type="radio" name="ssex" value="女"<c:if test="${all.ssex=='女'}">checked="checked"</c:if>>女 <br>
学生年龄:<input type="text" name="sage" value="${all.sage}"/> <br>
班级编号:<input type="text" name="scid" value="${all.scid}"/> <br>
<input type="submit" value="提交"/>
</form>
</body>
</html>