• ssm(增删改查、拦截器、过滤器)


    1、数据库

    Field       Type         Collation        Null    Key     Default  Extra   Privileges                       Comment  
    ----------  -----------  ---------------  ------  ------  -------  ------  -------------------------------  ---------
    teacherno   char(6)      utf8_general_ci  NO      PRI     (NULL)           select,insert,update,references           
    tname       varchar(8)   utf8_general_ci  YES             (NULL)           select,insert,update,references           
    major       varchar(20)  utf8_general_ci  YES             (NULL)           select,insert,update,references           
    prof        varchar(8)   utf8_general_ci  YES             (NULL)           select,insert,update,references           
    department  varchar(20)  utf8_general_ci  YES             (NULL)           select,insert,update,references      

    2、在WEB-INF目录下,配置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">
        <!-- 前端控制器 -->
        <servlet>
            <servlet-name>springmvc</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <!--绑定springmvc的配置文件-->
            <init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>classpath:applicationContext.xml</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup><!--启动服务器即创建-->
        </servlet>
        <servlet-mapping>
            <servlet-name>springmvc</servlet-name>
            <url-pattern>/</url-pattern>
        </servlet-mapping>
        <filter>
            <filter-name>EncodingFilter</filter-name>
            <filter-class>pers.zhb.filter.EncodingFilter</filter-class>
            <init-param>
                <param-name>encoding</param-name>
                <param-value>utf-8</param-value>
            </init-param>
        </filter>
        <filter-mapping>
            <filter-name>EncodingFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    </web-app>

    创建过滤器:

    public class EncodingFilter implements Filter {
        public void init(FilterConfig filterConfig) throws ServletException {
    
        }
    
        public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
            servletRequest.setCharacterEncoding("utf-8");
            servletResponse.setCharacterEncoding("utf-8");
            filterChain.doFilter(servletRequest,servletResponse);
        }
    
        public void destroy() {
    
        }
    }

    3、配置applicationContext.xml配置文件,里面包含其它的配置

    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"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans.xsd
           http://www.springframework.org/schema/mvc
           https://www.springframework.org/schema/mvc/spring-mvc.xsd">
           <import resource="classpath:spring-dao.xml"></import>
           <import resource="classpath:spring-service.xml"></import>
           <import resource="classpath:spring-mvc.xml"></import>
           <mvc:interceptors>
                  <mvc:interceptor>
                         <mvc:mapping path="/**"></mvc:mapping><!--包括该请求下的所有请求-->
                         <bean class="pers.zhb.config.MyInterceptor"></bean>
                  </mvc:interceptor>
           </mvc:interceptors>
    </beans>

    在配置文件中对拦截器配置的时候,<mvc:mapping path="/**"></mvc:mapping>定义的是拦截的范围

    拦截器:当要跳转到登录界面或者已经在登录界面要提交登录信息的时候或者session不为空(已经登录)不做拦截,其他情况(如:未登录,session为空)则重定向到登录界面提示用户登录后才能进入主页

    public class MyInterceptor implements HandlerInterceptor {
        public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
            HttpSession session=request.getSession();
            if(request.getRequestURI().contains("gologin")){
                return true;
            }
            if(request.getRequestURI().contains("login")){
                return true;
            }
            if(session.getAttribute("userInfo")!=null){//已经登录了
                return true;
            }
            request.getRequestDispatcher("/jsp/login.jsp").forward(request,response);
            return false;
        }
    }

    配置文件:spring-service.xml,注入dao层依赖,配置事务

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:aop="http://www.springframework.org/schema/aop"
           xmlns="http://www.springframework.org/schema/beans"
           xmlns:tx="http://www.springframework.org/schema/tx"
           xmlns:context="http://www.springframework.org/schema/context"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans.xsd
           http://www.springframework.org/schema/aop
           http://www.springframework.org/schema/aop/spring-aop.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">
        <import resource="classpath:spring-dao.xml"></import>
        <!--扫描service下的所有包-->
        <context:component-scan base-package="pers.zhb.service"></context:component-scan>
        <!--将我们所有的业务类注入到spring,可以通过配置或者注解的方式来实现-->
        <bean id="TeacherServiceImpl" class="pers.zhb.service.TeacherServiceImpl">
            <property name="teacherMapper" ref="teacherMapper"/>
        </bean>
        <!--声明式事务配置-->
        <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
            <property name="dataSource" ref="dataSource"></property>
        </bean>
        <!--aop事务支持,需要导包:aspectj-->
        <!--结合aop实现事务的织入-->
        <!--配置事务通知-->
        <tx:advice id="txAdvice" transaction-manager="txManager">
             <tx:attributes>
                 <tx:method name="*" propagation="REQUIRED"/>
             </tx:attributes>
        </tx:advice>
        <aop:config>
            <aop:pointcut id="txPointCut" expression="execution(* pers.zhb.dao.*.*(..))"/>
            <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointCut"></aop:advisor>
    
        </aop:config>
        <aop:aspectj-autoproxy  proxy-target-class="true"/>
    </beans>

    配置文件:spring-dao.xml,配置数据库连接池

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:context="http://www.springframework.org/schema/context"
           xmlns="http://www.springframework.org/schema/beans"
           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">
           <!--关联数据库文件-->
           <context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder>
           <!--连接池-->
           <bean name="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
             <property name="driverClass" value="${jdbc.driver}"></property>
             <property name="jdbcUrl" value="${jdbc.url}"></property>
             <property name="user" value="${jdbc.username}"></property>
             <property name="password" value="${jdbc.password}"></property>
           </bean>
           <!--sqlSessionFactory-->
           <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
               <property name="dataSource" ref="dataSource"></property>
               <property name="configLocation" value="classpath:mybatis-config.xml"></property>
           </bean>
           <!--配置dao接口扫描包,动态实现dao接口,可以注入到spring容器中-->
           <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
               <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
               <property name="basePackage" value="pers.zhb.dao"></property>
           </bean>
        </beans>

    spring-dao.xml又牵涉到两个配置文件:

    mybatis-config.xml:在整合ssm前,数据源是从mybatis获取的,整合之后,数据源直接从spring获取

    <?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>
        <!--配置数据源,与spring整合以后,交给spring去做-->
        <typeAliases>
            <package name="pers.zhb.pojo"></package>
        </typeAliases>
        <mappers>
            <mapper class="pers.zhb.dao.TeacherMapper"></mapper>
        </mappers>
    </configuration>

    数据库信息:jdbc.properties

    jdbc.driver=com.mysql.jdbc.Driver
    jdbc.url=jdbc:mysql://localhost:3306/stu_mangement
    jdbc.username=root
    jdbc.password=root

    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: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.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd">
    
        <!--自动扫描包,让指定包下的注解生效,由IOC容器统一管理-->
        <context:component-scan base-package="pers.zhb"></context:component-scan>
        <!--让Springmvc不处理静态资源,如css、js等-->
        <mvc:default-servlet-handler></mvc:default-servlet-handler>
        <!--使得注解生效-->
        <mvc:annotation-driven></mvc:annotation-driven>
        <!--视图解析器,前缀和后缀-->
        <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" id="internalResourceViewResolver">
            <property name="prefix" value="/jsp/"></property>
            <property name="suffix" value=".jsp"></property>
        </bean>
    </beans>

    4、dao层

    (1)接口:

    public interface TeacherMapper {
        int addTeacher(Teacher teacher);
        int deleteTeacherById(String teacherno);
        int updateTeacher(Teacher teacher);
        Teacher queryTeacherById(@Param("teacherno") String teacherno);
        List<Teacher> queryAllTeacher();
        List<Teacher> queryTeacherByMajor(@Param("major") String major);
    }

    (2)配置:

    <?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="pers.zhb.dao.TeacherMapper">
        <insert id="addTeacher" parameterType="teacher">
           INSERT INTO teacher VALUES(#{teacherno},#{tname},#{major},#{prof},#{department})
        </insert>
    
        <delete id="deleteTeacherById" parameterType="String">
           delete from teacher where teacherno=#{teacherno}
        </delete>
    
        <update id="updateTeacher" parameterType="teacher">
           update teacher
           set prof=#{prof},tname=#{tname},major=#{major},department=#{department}
           where teacherno=#{teacherno}
        </update>
    
        <select id="queryTeacherById" resultType="Teacher">
              select * from teacher where teacherno=#{teacherno}
        </select>
    
        <select id="queryAllTeacher" resultType="Teacher">
            select * from teacher
        </select>
    
        <select id="queryTeacherByMajor" resultType="Teacher">
            select * from teacher where major=#{major}
        </select>
    </mapper>

    5、service层

    (1)接口:

    public interface TeacherService {
        void addTeacher(Teacher teacher);
        int deleteTeacherById(String teacherno);
        int updateTeacher(Teacher teacher);
        Teacher queryTeacherById(String teacherno);
        List<Teacher> queryAllTeacher();
        List<Teacher> queryTeacherByMajor(String major);
    }

    (2)接口的实现类:

    import java.util.List;
    @Service("TeacherServiceImpl")
    public class TeacherServiceImpl implements TeacherMapper {
        @Autowired
        private TeacherMapper teacherMapper;
    
        public void setTeacherMapper(TeacherMapper teacherMapper){
            this.teacherMapper=teacherMapper;
        }
    
        public int addTeacher(Teacher teacher) {
            return teacherMapper.addTeacher(teacher);
        }
    
        public int deleteTeacherById(String teacherno) {
            return teacherMapper.deleteTeacherById(teacherno);
        }
    
        public int updateTeacher(Teacher teacher) {
            return teacherMapper.updateTeacher(teacher);
        }
    
        public Teacher queryTeacherById(String teacherno) {
            return teacherMapper.queryTeacherById(teacherno);
        }
    
        public List<Teacher> queryAllTeacher() {
            return teacherMapper.queryAllTeacher();
        }
    
        public List<Teacher> queryTeacherByMajor(String major) {
            return teacherMapper.queryTeacherByMajor(major);
        }
    }

    6、controller层:分为两个,一个是登录,一个管理教师信息

    登录:

    @Controller
    @RequestMapping("user")
    public class LoginController {
        @RequestMapping("main")
        public String main(){
            return "allTeacher";
        }
    
        @RequestMapping("gologin")
        public String login(){
            return "login";
        }
    
        @RequestMapping("login")
        public String login(HttpSession session, String username, String password, Model model){
            session.setAttribute("userInfo",username);
            model.addAttribute("username",username);
            return "forward:/teacher/allTeacher";
        }
    
        @RequestMapping("goOut")
        public String goOut(HttpSession session){
            session.removeAttribute("userInfo");
            return "index";
        }
    }

    教师信息管理:

    @Controller
    @RequestMapping("teacher")
    public class TeacherController {
        @Autowired
        @Qualifier("TeacherServiceImpl")
        private TeacherServiceImpl teacherService;
        @RequestMapping("allTeacher")//查询全部教师信息
        public String list(Model model){
            List<Teacher> list = teacherService.queryAllTeacher();
            model.addAttribute("list",list);
            return "allTeacher";
        }
        @RequestMapping("toAddPaper")
        public String toAddPaper(){//跳转到增加教师页面
            return "addTeacher";
        }
        @RequestMapping("addTeacher")//添加教师
        public String addTeacher(Teacher teacher){
            teacherService.addTeacher(teacher);
            return "redirect:/teacher/allTeacher";
        }
        @RequestMapping("toUpdatePaper")//跳转到修改页面
        public String toUpdatePaper(String id,Model model){
            Teacher teacher=teacherService.queryTeacherById(id);
            model.addAttribute("teachers",teacher);
            return "updateTeacher";
        }
        @RequestMapping("updateTeacher")
        public String updateTeacher(Teacher teacher){
            teacherService.updateTeacher(teacher);
            return "redirect:/teacher/allTeacher";
        }
        @RequestMapping("/deleteTeacher/{tid}")
        public String deleteTeacher(@PathVariable("tid") String teacherno){
            teacherService.deleteTeacherById(teacherno);
            return "redirect:/teacher/allTeacher";
        }
        @RequestMapping("queryTeacherByMajor")
        public String queryTeacherByMajor(String queryTeacherMajor,String username,Model model){
            String string=null;
            List<Teacher> teachers= teacherService.queryTeacherByMajor(queryTeacherMajor);
            if(teachers.isEmpty()){
                string= "redirect:/teacher/allTeacher";
                model.addAttribute("e","未查询到相关信息");
            }else{
                string= "teachersByMajor";
                model.addAttribute("teachers",teachers);
                model.addAttribute("username",username);
            }
            return string;
        }
    }

    7、pojo:用到的是lombok插件,使代码更加简洁

    import lombok.*;
    @Setter
    @Getter
    @ToString
    @AllArgsConstructor
    @NoArgsConstructor
    public class Teacher {
            private String teacherno;
            private String tname;
            private String major;
            private String prof;
            private String department;
    }

    8、界面

    (1)添加教师:

    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
    <head>
        <title>Title</title>
        <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    </head>
    <body>
    <div class="container">
        <div class="row clearfix"><!--清除浮动-->
            <div class="col-md-12 column"><!--12列-->
                <div class="page-header">
                    <h1>
                        <small>添加教师信息</small>
                    </h1>
                </div>
            </div>
        </div>
        <form action="${pageContext.request.contextPath}/teacher/addTeacher" method="post">
            <div class="form-group">
                <label for="teacherno">编号</label>
                <input type="text" class="form-control" id="teacherno" name="teacherno">
            </div>
            <div class="form-group">
                <label for="tname">姓名</label>
                <input type="text" class="form-control" id="tname" name="tname">
            </div>
            <div class="form-group">
                <label for="major">专业</label>
                <input type="text" class="form-control" id="major" name="major">
            </div>
            <div class="form-group">
                <label for="prof">职称</label>
                <input type="text" class="form-control" id="prof" name="prof">
            </div>
            <div class="form-group">
                <label for="department">学院</label>
                <input type="text" class="form-control" id="department" name="department">
            </div>
            <div class="form-group">
                <input type="submit" class="form-control" value="添加">
            </div>
        </form>
    </div>
    
    </body>
    </html>

    (2)显示所有教师信息(主页):

    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
    <head>
        <title>教师信息</title>
        <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
        <!--不用导包了-->
    </head>
    <body>
    <center><h1>教师信息</h1></center>
    <div class="container">
        <div class="row clearfix"><!--清除浮动-->
            <div class="col-md-12 column"><!--12列-->
                <div class="page-header">
                    <h1>
                        <small>教师列表——显示所有数据</small>
                    </h1>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12" colum>
                    <span>${username}</span>
                    <p>
                        <a href="${pageContext.request.contextPath}/user/goOut">注销</a>
                    </p>
                </div>
                <div class="col-md-4" colum>
                    <a class="btn btn-primary" href="${pageContext.request.contextPath}/teacher/toAddPaper">新增教师信息</a>
                </div>
                <div class="col-md-4" colum></div>
                <div class="col-md-4">
                    <form action="${pageContext.request.contextPath}/teacher/queryTeacherByMajor" method="post" style="float: right" class="form-inline">
                        <span style="color: red; font-weight: bold">${e}</span>
                        <input type="text" name="queryTeacherMajor" class="form-control" placeholder="请输入要查询的教师专业">
                        <input type="submit" value="查询" class="btn btn-primary">
                    </form>
                </div>
            </div>
        </div>
        <div class="row clearfix">
            <div class="col-md-12 column">
                <table class="table table-hover table-striped">
                    <thead>
                    <tr>
                        <th>编号</th>
                        <th>姓名</th>
                        <th>专业</th>
                        <th>职称</th>
                        <th>学院</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                <tbody>
                <c:forEach var="teacher" items="${list}">
                    <tr>
                        <td>${teacher.teacherno}</td>
                        <td>${teacher.tname}</td>
                        <td>${teacher.major}</td>
                        <td>${teacher.prof}</td>
                        <td>${teacher.department}</td>
                        <td>
                            <a href="${pageContext.request.contextPath}/teacher/toUpdatePaper?id=${teacher.teacherno}">修改</a>
                            &nbsp; | &nbsp;
                            <a href="${pageContext.request.contextPath}/teacher/deleteTeacher/${teacher.teacherno}">删除</a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
                </table>
            </div>
        </div>
    </div>
    </body>
    </html>

    点击注销后会跳转到起始页,本质是清除session。

    (3)起始页:

    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
    <head>
        <title>Title</title>
        <style>
            a{
                text-decoration: none;
                color: black;
                font-size: 18px;
            }
            h1{
                 180px;
                height: 38px;
                margin: 100px auto;
                text-align: center;
                line-height: 38px;
                background: deepskyblue;
            }
        </style>
    </head>
    <body>
         <center>
            <h2>起始页</h2>
         </center>
         <h1><a href="${pageContext.request.contextPath}/user/gologin">登录</a></h1>
         <h1><a href="${pageContext.request.contextPath}/teacher/allTeacher">进入教师信息页面首页</a></h1>
    </body>
    </html>

    (4)登录页:

    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
    <head>
        <title>Login</title>
    </head>
    <!--在WEB-INF下的所有页面或资源,只能通过servlet或controller进行访问-->
    <body>
       <h1>登录页面</h1>
    <form action="${pageContext.request.contextPath}/user/login" method="post">
        用户名:<input type="text" name="username">
        密码:<input type="password" name="password">
        <input type="submit" value="提交">
    </form>
    </body>
    </html>

    (5)条件查询页:

    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
    <head>
        <title>教师信息</title>
        <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
        <!--不用导包了-->
    </head>
    <body>
    <center><h1>教师信息</h1></center>
    <div class="container">
        <div class="row clearfix"><!--清除浮动-->
            <div class="col-md-12 column"><!--12列-->
                <div class="page-header">
                    <h1>
                        <small>教师列表——根据教师职称查询</small>
                    </h1>
                </div>
            </div>
            <div class="row">
                <div class="col-md-4" colum>
                    <a class="btn btn-primary" href="${pageContext.request.contextPath}/teacher/allTeacher">返回首页</a>
                </div>
            </div>
        </div>
        <div class="row clearfix">
            <div class="col-md-12 column">
                <table class="table table-hover table-striped">
                    <thead>
                    <tr>
                        <th>编号</th>
                        <th>姓名</th>
                        <th>专业</th>
                        <th>职称</th>
                        <th>学院</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach var="teacher" items="${teachers}">
                        <tr>
                            <td>${teacher.teacherno}</td>
                            <td>${teacher.tname}</td>
                            <td>${teacher.major}</td>
                            <td>${teacher.prof}</td>
                            <td>${teacher.department}</td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    </body>
    </html>

    (6)更新教师信息页:

    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
    <head>
        <title>修改教师信息</title>
        <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    </head>
    <body>
    <div class="container">
        <div class="row clearfix"><!--清除浮动-->
            <div class="col-md-12 column"><!--12列-->
                <div class="page-header">
                    <h1>
                        <small>修改教师信息</small>
                    </h1>
                </div>
            </div>
        </div>
        <form action="${pageContext.request.contextPath}/teacher/updateTeacher" method="post">
            <input type="hidden" name="teacherno" value="${teachers.teacherno}">
            <div class="form-group">
                <label for="tname">姓名</label>
                <input type="text" class="form-control" id="tname" name="tname" value="${teachers.tname}">
            </div>
            <div class="form-group">
                <label for="major">专业</label>
                <input type="text" class="form-control" id="major" name="major" value="${teachers.major}">
            </div>
            <div class="form-group">
                <label for="prof">职称</label>
                <input type="text" class="form-control" id="prof" name="prof" value="${teachers.prof}">
            </div>
            <div class="form-group">
                <label for="department">学院</label>
                <input type="text" class="form-control" id="department" name="department"  value="${teachers.department}">
            </div>
            <div class="form-group">
                <input type="submit" class="form-control" value="确定修改">
            </div>
        </form>
    </div>
    
    </body>
    </html>

     在进入修改页面的时候会根据ID查询要修改的教师,并将该教师的信息回显在表单中

  • 相关阅读:
    利用google kaptcha完成登陆动态验证码
    Linux和Windows环境下安装Nginx
    将图片设定为固定大小
    将xls格式的Excel转换成图片
    将pdf格式的文件转换成图片
    SSH连接工具类
    java判断ip内外网
    jenkins安装与使用
    Eclipse快捷键大全
    serialVersionUID的作用
  • 原文地址:https://www.cnblogs.com/zhai1997/p/12911541.html
Copyright © 2020-2023  润新知