欢迎来到Jsp编程课时十二——今天实现的目标是。@1将数据库的数据发送到浏览器。@2利用浏览器实现对数据库的增删改查操作。@3理解MVC三层架构的定义。(三)

简介: 欢迎来到Jsp编程课时十二——今天实现的目标是。@1将数据库的数据发送到浏览器。@2利用浏览器实现对数据库的增删改查操作。@3理解MVC三层架构的定义。(三)

后端代码第三部分

package com.student.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.student.service.IStudentService;
import com.student.service.StudentServiceImp;
/**
 * Servlet implementation class AddStudentServlect
 */
@WebServlet("/AddStudentServlect")
public class AddStudentServlect extends HttpServlet {
  private static final long serialVersionUID = 1L;
    /**
     * @see HttpServlet#HttpServlet()
     */
    public AddStudentServlect() {
        super();
        // TODO Auto-generated constructor stub
    }
  /**
   * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    response.getWriter().append("Served at: ").append(request.getContextPath());
  }
  /**
   * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String name=request.getParameter("name");
    String age=request.getParameter("age");
    IStudentService service =new StudentServiceImp();
    int i=service.add(name,Integer.parseInt(age));
    if(i>0) {
      System.out.println("增加成功");
      response.sendRedirect("HomeServlet");
    }
  }
}
package com.student.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.student.service.IStudentService;
import com.student.service.StudentServiceImp;
/**
 * Servlet implementation class DeleteStudent
 */
@WebServlet("/DeleteStudent")
public class DeleteStudent extends HttpServlet {
  private static final long serialVersionUID = 1L;
    /**
     * @see HttpServlet#HttpServlet()
     */
    public DeleteStudent() {
        super();
        // TODO Auto-generated constructor stub
    }
  /**
   * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
      String id=request.getParameter("id");
      IStudentService service =new StudentServiceImp();
    int i=  service.delete(Integer.parseInt(id));
    if(i>0) {
      response.sendRedirect("HomeServlet");
    }
  }
  /**
   * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  }
}
package com.student.controller;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.student.service.IStudentService;
import com.student.service.StudentServiceImp;
/**
 * Servlet implementation class HomeServlet
 */
@WebServlet("/HomeServlet")
public class HomeServlet extends HttpServlet {
  private static final long serialVersionUID = 1L;
    /**
     * @see HttpServlet#HttpServlet()
     */
    public HomeServlet() {
        super();
        // TODO Auto-generated constructor stub
    }
  /**
   * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    //将浏览器的任务接收,发给业务逻辑层处理
    IStudentService service=new StudentServiceImp();
    List<Map<String, Object>> oList=service.getStudents();
    //
    HttpSession session =request.getSession();
    //将从数据库中查询出来的数据存储至request
    session.setAttribute("students", oList);
    //请求转发跳转页面
    request.getRequestDispatcher("index.jsp").forward(request, response); 
  }
  /**
   * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    doGet(request, response);
  }
}
package com.student.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.student.service.IStudentService;
import com.student.service.StudentServiceImp;
/**
 * Servlet implementation class UpdateStudentServlet
 */
@WebServlet("/UpdateStudentServlet")
public class UpdateStudentServlet extends HttpServlet {
  private static final long serialVersionUID = 1L;
    /**
     * @see HttpServlet#HttpServlet()
     */
    public UpdateStudentServlet() {
        super();
        // TODO Auto-generated constructor stub
    }
  /**
   * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    response.getWriter().append("Served at: ").append(request.getContextPath());
  }
  /**
   * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String id=request.getParameter("id");
    String name=request.getParameter("name");
    String age=request.getParameter("age");
    IStudentService service=new StudentServiceImp();
    int i=service.update(Integer.parseInt(id), name, Integer.parseInt(age));
    if (i>0) {
      //修改成功
      response.sendRedirect("HomeServlet");
    }
  }
}
package com.student.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.student.service.IStudentService;
import com.student.service.StudentServiceImp;
/**
 * Servlet implementation class UpdateStudentServlet
 */
@WebServlet("/UpdateStudentServlet")
public class UpdateStudentServlet extends HttpServlet {
  private static final long serialVersionUID = 1L;
    /**
     * @see HttpServlet#HttpServlet()
     */
    public UpdateStudentServlet() {
        super();
        // TODO Auto-generated constructor stub
    }
  /**
   * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    response.getWriter().append("Served at: ").append(request.getContextPath());
  }
  /**
   * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String id=request.getParameter("id");
    String name=request.getParameter("name");
    String age=request.getParameter("age");
    IStudentService service=new StudentServiceImp();
    int i=service.update(Integer.parseInt(id), name, Integer.parseInt(age));
    if (i>0) {
      //修改成功
      response.sendRedirect("HomeServlet");
    }
  }
}


package com.student.dao;
/**
 * 数据访问层操作学生表的接口
 * @author admin
 *
 */
import java.util.List;
import java.util.Map;
public interface IStudentDao {
  //接收业务逻辑层的任务,查询出所有学生信息
  List<Map<String, Object>> getStudents();
  //接收信息
  int add(String name,int age);
  //Dao修改操作
  int update(int id,String name,int age);
  //删除
  int delete(int id);
}
package com.student.dao;
/**
 * 数据访问层操作学生表的接口
 * @author admin
 *
 */
import java.util.List;
import java.util.Map;
public interface IStudentDao {
  //接收业务逻辑层的任务,查询出所有学生信息
  List<Map<String, Object>> getStudents();
  //接收信息
  int add(String name,int age);
  //Dao修改操作
  int update(int id,String name,int age);
  //删除
  int delete(int id);
}
package com.student.dao;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import com.student.utils.DBUtil;
/**
 * 数据访问操作学生表的实现类
 * @author admin
 *
 */
public class StudentDaoImp implements IStudentDao {
  @Override
  public List<Map<String, Object>> getStudents() {
    String sql="select * from tb_student2";
    return DBUtil.jt.queryForList(sql);
  }
  @Override
  public int add(String name, int age) {
    // TODO Auto-generated method stub
    String sql="insert into tb_student2(name,age) values (?,?)";
    return DBUtil.jt.update(sql,name,age);
  }
  //修改
  @Override
  public int update(int id, String name, int age) {
    String sql="update tb_student2 set name=?,age=? where id=?";
    return DBUtil.jt.update(sql,name,age,id);
  }
  @Override
  public int delete(int id) {
    // TODO Auto-generated method stub
    String sql="delete from tb_student2 where id=?";
    return DBUtil.jt.update(sql,id);
  }
  }
package com.student.dao;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import com.student.utils.DBUtil;
/**
 * 数据访问操作学生表的实现类
 * @author admin
 *
 */
public class StudentDaoImp implements IStudentDao {
  @Override
  public List<Map<String, Object>> getStudents() {
    String sql="select * from tb_student2";
    return DBUtil.jt.queryForList(sql);
  }
  @Override
  public int add(String name, int age) {
    // TODO Auto-generated method stub
    String sql="insert into tb_student2(name,age) values (?,?)";
    return DBUtil.jt.update(sql,name,age);
  }
  //修改
  @Override
  public int update(int id, String name, int age) {
    String sql="update tb_student2 set name=?,age=? where id=?";
    return DBUtil.jt.update(sql,name,age,id);
  }
  @Override
  public int delete(int id) {
    // TODO Auto-generated method stub
    String sql="delete from tb_student2 where id=?";
    return DBUtil.jt.update(sql,id);
  }
  }
package com.student.utils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import javax.sql.DataSource;
import org.springframework.jdbc.core.JdbcTemplate;
import com.alibaba.druid.pool.DruidDataSourceFactory;
/**
 * 连接数据库的工具类
 * @author admin
 *
 */
public class DBUtil {
  public static JdbcTemplate jt=null;
  //获得druid配置的数据库连接池
  static {
    //使用反射机制获得druid配置文件转换成输入流
    InputStream is= DBUtil.class.getClassLoader()
      .getResourceAsStream("com/student/utils/druid.properties");
    Properties properties=new Properties();
    try {
      //将输入流导入properties对象
      properties.load(is);
      //获得数据库连接池
      DataSource ds=DruidDataSourceFactory.createDataSource(properties);
      jt=new JdbcTemplate(ds);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
package com.util;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.entity.Book;
/**
 * 放图书的内容工具类
 * @author MZFAITHDREAM
 *2021/10/19
 */
public class BooksDBUtil {
  public static List<Book> getBooks(){
    Book book1 =new Book("java程序设计","自由", "39元","人民日报","");
    Book book2 =new Book("java网站设计","马玉", "89元","清华","");
    Book book3 =new Book("javascript程序设计","不变", "239元","人民日报","");
    Book book4 =new Book("jquery程序设计","胡毅", "189元","江西出版社","");
    Book book5=new Book("mysql程序设计","ok", "179元","北大","");
    Book book6 =new Book("Sping框架设计","胡三", "129元","人民日报","");
    Book book7 =new Book("java高级编程","呼万岁", "159元","河南出版社","");
    Book book8=new Book("ps设计","ok", "239元","西安出版社","");
    Book book9 =new Book("Sping框架设计","胡三", "129元","人民日报","");
    Book book10=new Book("Java程序设计", "马云", "78.0元", "人民邮电出版社", "");
    Book book11=new Book("Jsp网络编程", "马化腾", "118.0元", "清华大学出版社", "");
    Book book12=new Book("Python爬虫技术", "李彦宏", "65.0元", "电子工业出版社", "");
    Book book13=new Book("网页程序设计", "任正非", "38.0元", "江西出版社", "");
    Book book14=new Book("MySQL程序教程", "雷军", "59.0元", "吉林出版社", "");
    Book book15=new Book("Spring框架技术", "马小云", "46.0元", "人民邮电出版社", "");
    List <Book> oBooks=new ArrayList<Book>();
    oBooks.add(book1);
    oBooks.add(book2);
    oBooks.add(book3);
    oBooks.add(book4);
    oBooks.add(book5);
    oBooks.add(book6);
    oBooks.add(book7);
    oBooks.add(book8);
    oBooks.add(book9);
    oBooks.add(book10);
    oBooks.add(book11);
    oBooks.add(book12);
    oBooks.add(book13);
    oBooks.add(book14);
    oBooks.add(book15);
    return oBooks;
  }
  public static String getNowTime() {
    Date date=new Date();
    //2021年10月19日
    SimpleDateFormat sdf=new SimpleDateFormat ("YYYY年MM月DD日HH:mm:ss");
    //要求当前时间进行格式化
    String time=sdf.format(date);
    return time;
  }
}
package com.util;
import java.sql.Connection;
public class Time {
  public static int time=60*60*60;
  static Connection time() {
    while (time>0) {
      time--;
      try {
        Thread.sleep(1000);
        int hh=time/1/1%1;
        int mm=time/60%1;
        int ss=time%6;
        if(hh==0 &&mm==0 && ss==0) {
          break;
        }
        System.out.println("0小时"+hh+"Сʱ"+mm+"分钟"+ss+"秒");
      } catch (InterruptedException e) {
        // TODO: handle exception
    }finally {
      System.out.println("正在跳转页面哦 ServlectB");
      System.out.println(".......真在跳转页面 ");
    }
    }
    return null;
  }
  public static void main(String[] args) {
    // TODO Auto-generated method stub
    time();
  }
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:jsp="http://java.sun.com/xml/ns/javaee/jsp" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>MVCImport</display-name>
  <welcome-file-list>
    <welcome-file>ZhuCe.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>ServlectOne</servlet-name>
    <servlet-class>com.Servlect.ServlectOne</servlet-class>
    <init-param>
      <param-name>SFZ</param-name>
      <param-value>360429100056781234</param-value>
    </init-param>
  </servlet>
  <context-param>
    <param-name>LQ</param-name>
    <param-value>篮球</param-value>
  </context-param>
  <servlet-mapping>
    <servlet-name>ServlectOne</servlet-name>
    <url-pattern>/ServlectOne</url-pattern>
  </servlet-mapping>
  <filter>
    <filter-name>MyFilter4</filter-name>
    <filter-class>com.Filter.MyFilter4</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>MyFilter4</filter-name>
    <url-pattern>/Servlect1</url-pattern>
  </filter-mapping>
  <listener>
    <listener-class>com.Listener.Listener</listener-class>
  </listener>
  <context-param>
    <param-name>USER</param-name>
    <param-value>ABC</param-value>
  </context-param>
  <context-param>
    <param-name>QQ</param-name>
    <param-value>123456</param-value>
  </context-param>
  <context-param>
    <param-name>PSD</param-name>
    <param-value>123456</param-value>
  </context-param>
  <context-param>
    <param-name>SJ</param-name>
    <param-value>18172928419</param-value>
  </context-param>
  <context-param>
    <param-name>HOME</param-name>
    <param-value>江西省</param-value>
  </context-param>
  <jsp-config>
    <taglib>
      <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
      <taglib-location>/WEB-INF/c.tld</taglib-location>
    </taglib>
  </jsp-config>
</web-app>
<?xml version="1.0" encoding="UTF-8" ?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
    version="2.0">
  <description>JSTL 1.1 core library</description>
  <display-name>JSTL core</display-name>
  <tlib-version>1.1</tlib-version>
  <short-name>c</short-name>
  <uri>http://java.sun.com/jsp/jstl/core</uri>
  <validator>
    <description>
        Provides core validation features for JSTL tags.
    </description>
    <validator-class>
        org.apache.taglibs.standard.tlv.JstlCoreTLV
    </validator-class>
  </validator>
  <tag>
    <description>
        Catches any Throwable that occurs in its body and optionally
        exposes it.
    </description>
    <name>catch</name>
    <tag-class>org.apache.taglibs.standard.tag.common.core.CatchTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
Name of the exported scoped variable for the
exception thrown from a nested action. The type of the
scoped variable is the type of the exception thrown.
        </description>
        <name>var</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
  </tag>
  <tag>
    <description>
  Simple conditional tag that establishes a context for
  mutually exclusive conditional operations, marked by
  &lt;when&gt; and &lt;otherwise&gt;
    </description>
    <name>choose</name>
    <tag-class>org.apache.taglibs.standard.tag.common.core.ChooseTag</tag-class>
    <body-content>JSP</body-content>
  </tag>
  <tag>
    <description>
  Simple conditional tag, which evalutes its body if the
  supplied condition is true and optionally exposes a Boolean
  scripting variable representing the evaluation of this condition
    </description>
    <name>if</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.core.IfTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
The test condition that determines whether or
not the body content should be processed.
        </description>
        <name>test</name>
        <required>true</required>
        <rtexprvalue>true</rtexprvalue>
  <type>boolean</type>
    </attribute>
    <attribute>
        <description>
Name of the exported scoped variable for the
resulting value of the test condition. The type
of the scoped variable is Boolean.        
        </description>
        <name>var</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Scope for var.
        </description>
        <name>scope</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
  </tag>
  <tag>
    <description>
        Retrieves an absolute or relative URL and exposes its contents
        to either the page, a String in 'var', or a Reader in 'varReader'.
    </description>
    <name>import</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.core.ImportTag</tag-class>
    <tei-class>org.apache.taglibs.standard.tei.ImportTEI</tei-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
The URL of the resource to import.
        </description>
        <name>url</name>
        <required>true</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Name of the exported scoped variable for the
resource's content. The type of the scoped
variable is String.
        </description>
        <name>var</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Scope for var.
        </description>
        <name>scope</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Name of the exported scoped variable for the
resource's content. The type of the scoped
variable is Reader.
        </description>
        <name>varReader</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Name of the context when accessing a relative
URL resource that belongs to a foreign
context.
        </description>
        <name>context</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Character encoding of the content at the input
resource.
        </description>
        <name>charEncoding</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
  </tag>
  <tag>
    <description>
  The basic iteration tag, accepting many different
        collection types and supporting subsetting and other
        functionality
    </description>
    <name>forEach</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.core.ForEachTag</tag-class>
    <tei-class>org.apache.taglibs.standard.tei.ForEachTEI</tei-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
Collection of items to iterate over.
        </description>
  <name>items</name>
  <required>false</required>
  <rtexprvalue>true</rtexprvalue>
  <type>java.lang.Object</type>
    </attribute>
    <attribute>
        <description>
If items specified:
Iteration begins at the item located at the
specified index. First item of the collection has
index 0.
If items not specified:
Iteration begins with index set at the value
specified.
        </description>
  <name>begin</name>
  <required>false</required>
  <rtexprvalue>true</rtexprvalue>
  <type>int</type>
    </attribute>
    <attribute>
        <description>
If items specified:
Iteration ends at the item located at the
specified index (inclusive).
If items not specified:
Iteration ends when index reaches the value
specified.
        </description>
  <name>end</name>
  <required>false</required>
  <rtexprvalue>true</rtexprvalue>
  <type>int</type>
    </attribute>
    <attribute>
        <description>
Iteration will only process every step items of
the collection, starting with the first one.
        </description>
  <name>step</name>
  <required>false</required>
  <rtexprvalue>true</rtexprvalue>
  <type>int</type>
    </attribute>
    <attribute>
        <description>
Name of the exported scoped variable for the
current item of the iteration. This scoped
variable has nested visibility. Its type depends
on the object of the underlying collection.
        </description>
  <name>var</name>
  <required>false</required>
  <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Name of the exported scoped variable for the
status of the iteration. Object exported is of type
javax.servlet.jsp.jstl.core.LoopTagStatus. This scoped variable has nested
visibility.
        </description>
  <name>varStatus</name>
  <required>false</required>
  <rtexprvalue>false</rtexprvalue>
    </attribute>
  </tag>
  <tag>
    <description>
  Iterates over tokens, separated by the supplied delimeters
    </description>
    <name>forTokens</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.core.ForTokensTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
String of tokens to iterate over.
        </description>
  <name>items</name>
  <required>true</required>
  <rtexprvalue>true</rtexprvalue>
  <type>java.lang.String</type>
    </attribute>
    <attribute>
        <description>
The set of delimiters (the characters that
separate the tokens in the string).
        </description>
  <name>delims</name>
  <required>true</required>
  <rtexprvalue>true</rtexprvalue>
  <type>java.lang.String</type>
    </attribute>
    <attribute>
        <description>
Iteration begins at the token located at the
specified index. First token has index 0.
        </description>
  <name>begin</name>
  <required>false</required>
  <rtexprvalue>true</rtexprvalue>
  <type>int</type>
    </attribute>
    <attribute>
        <description>
Iteration ends at the token located at the
specified index (inclusive).
        </description>
  <name>end</name>
  <required>false</required>
  <rtexprvalue>true</rtexprvalue>
  <type>int</type>
    </attribute>
    <attribute>
        <description>
Iteration will only process every step tokens
of the string, starting with the first one.
        </description>
  <name>step</name>
  <required>false</required>
  <rtexprvalue>true</rtexprvalue>
  <type>int</type>
    </attribute>
    <attribute>
        <description>
Name of the exported scoped variable for the
current item of the iteration. This scoped
variable has nested visibility.
        </description>
  <name>var</name>
  <required>false</required>
  <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Name of the exported scoped variable for the
status of the iteration. Object exported is of
type
javax.servlet.jsp.jstl.core.LoopTag
Status. This scoped variable has nested
visibility.
        </description>
  <name>varStatus</name>
  <required>false</required>
  <rtexprvalue>false</rtexprvalue>
    </attribute>
  </tag>
  <tag>
    <description>
        Like &lt;%= ... &gt;, but for expressions.
    </description> 
    <name>out</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.core.OutTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
Expression to be evaluated.
        </description>
        <name>value</name>
        <required>true</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Default value if the resulting value is null.
        </description>
        <name>default</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Determines whether characters &lt;,&gt;,&amp;,'," in the
resulting string should be converted to their
corresponding character entity codes. Default value is
true.
        </description>
        <name>escapeXml</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
  </tag>
  <tag>
    <description>
        Subtag of &lt;choose&gt; that follows &lt;when&gt; tags
        and runs only if all of the prior conditions evaluated to
        'false'
    </description>
    <name>otherwise</name>
    <tag-class>org.apache.taglibs.standard.tag.common.core.OtherwiseTag</tag-class>
    <body-content>JSP</body-content>
  </tag>
  <tag>
    <description>
        Adds a parameter to a containing 'import' tag's URL.
    </description>
    <name>param</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.core.ParamTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
Name of the query string parameter.
        </description>
        <name>name</name>
        <required>true</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Value of the parameter.
        </description>
        <name>value</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
  </tag>
  <tag>
    <description>
        Redirects to a new URL.
    </description>
    <name>redirect</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.core.RedirectTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
The URL of the resource to redirect to.
        </description>
        <name>url</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Name of the context when redirecting to a relative URL
resource that belongs to a foreign context.
        </description>
        <name>context</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
  </tag>
  <tag>
    <description>
        Removes a scoped variable (from a particular scope, if specified).
    </description>
    <name>remove</name>
    <tag-class>org.apache.taglibs.standard.tag.common.core.RemoveTag</tag-class>
    <body-content>empty</body-content>
    <attribute>
        <description>
Name of the scoped variable to be removed.
        </description>
        <name>var</name>
        <required>true</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Scope for var.
        </description>
        <name>scope</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
  </tag>
 <tag>
    <description>
        Sets the result of an expression evaluation in a 'scope'
    </description>
    <name>set</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.core.SetTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
Name of the exported scoped variable to hold the value
specified in the action. The type of the scoped variable is
whatever type the value expression evaluates to.
        </description>
        <name>var</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Expression to be evaluated.
        </description>
        <name>value</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Target object whose property will be set. Must evaluate to
a JavaBeans object with setter property property, or to a
java.util.Map object.
        </description>
        <name>target</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Name of the property to be set in the target object.
        </description>
        <name>property</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Scope for var.
        </description>
        <name>scope</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
  </tag>
  <tag>
    <description>
        Creates a URL with optional query parameters.
    </description>
    <name>url</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.core.UrlTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
Name of the exported scoped variable for the
processed url. The type of the scoped variable is
String.
        </description>
        <name>var</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Scope for var.
        </description>
        <name>scope</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
URL to be processed.
        </description>
        <name>value</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Name of the context when specifying a relative URL
resource that belongs to a foreign context.
        </description>
        <name>context</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
  </tag>
  <tag>
    <description>
  Subtag of &lt;choose&gt; that includes its body if its
  condition evalutes to 'true'
    </description>
    <name>when</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.core.WhenTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
The test condition that determines whether or not the
body content should be processed.
        </description>
        <name>test</name>
        <required>true</required>
        <rtexprvalue>true</rtexprvalue>
  <type>boolean</type>
    </attribute>
  </tag>
</taglib>

最完整的小项目完成了对数据的增删改查·。

相关文章
|
3月前
|
NoSQL 关系型数据库 MySQL
微服务架构下的数据库选择:MySQL、PostgreSQL 还是 NoSQL?
在微服务架构中,数据库的选择至关重要。不同类型的数据库适用于不同的需求和场景。在本文章中,我们将深入探讨传统的关系型数据库(如 MySQL 和 PostgreSQL)与现代 NoSQL 数据库的优劣势,并分析在微服务架构下的最佳实践。
|
3月前
|
消息中间件 缓存 监控
优化微服务架构中的数据库访问:策略与最佳实践
在微服务架构中,数据库访问的效率直接影响到系统的性能和可扩展性。本文探讨了优化微服务架构中数据库访问的策略与最佳实践,包括数据分片、缓存策略、异步处理和服务间通信优化。通过具体的技术方案和实例分析,提供了一系列实用的建议,以帮助开发团队提升微服务系统的响应速度和稳定性。
|
1月前
|
存储 SQL Apache
Apache Doris 开源最顶级基于MPP架构的高性能实时分析数据库
Apache Doris 是一个基于 MPP 架构的高性能实时分析数据库,以其极高的速度和易用性著称。它支持高并发点查询和复杂分析场景,适用于报表分析、即席查询、数据仓库和数据湖查询加速等。最新发布的 2.0.2 版本在性能、稳定性和多租户支持方面有显著提升。社区活跃,已广泛应用于电商、广告、用户行为分析等领域。
Apache Doris 开源最顶级基于MPP架构的高性能实时分析数据库
|
1月前
|
缓存 关系型数据库 MySQL
高并发架构系列:数据库主从同步的 3 种方案
本文详解高并发场景下数据库主从同步的三种解决方案:数据主从同步、数据库半同步复制、数据库中间件同步和缓存记录写key同步,旨在帮助解决数据一致性问题。关注【mikechen的互联网架构】,10年+BAT架构经验倾囊相授。
高并发架构系列:数据库主从同步的 3 种方案
|
1月前
|
存储 Cloud Native NoSQL
云原生时代的数据库选型与架构设计
云原生时代的数据库选型与架构设计
25 0
|
2月前
|
设计模式 人工智能 算法
编程之旅:从代码到架构的感悟
【9月更文挑战第33天】在编程的世界里,代码不仅是实现功能的工具,更是连接思想与现实的桥梁。本文将通过个人的编程经历,分享从编写第一行代码到设计系统架构的旅程,探索编程背后的哲学和技术演变。我们将一起思考,如何在代码的海洋中找到自己的航向,以及在这个过程中如何不断成长和适应变化。
|
3月前
|
消息中间件 缓存 监控
优化微服务架构中的数据库访问:策略与实践
随着微服务架构的普及,如何高效管理和优化数据库访问成为了关键挑战。本文探讨了在微服务环境中优化数据库访问的策略,包括数据库分片、缓存机制、异步处理等技术手段。通过深入分析实际案例和最佳实践,本文旨在为开发者提供实际可行的解决方案,以提升系统性能和可扩展性。
|
3月前
|
存储 缓存 Java
JAVA并发编程系列(11)线程池底层原理架构剖析
本文详细解析了Java线程池的核心参数及其意义,包括核心线程数量(corePoolSize)、最大线程数量(maximumPoolSize)、线程空闲时间(keepAliveTime)、任务存储队列(workQueue)、线程工厂(threadFactory)及拒绝策略(handler)。此外,还介绍了四种常见的线程池:可缓存线程池(newCachedThreadPool)、定时调度线程池(newScheduledThreadPool)、单线程池(newSingleThreadExecutor)及固定长度线程池(newFixedThreadPool)。
|
4月前
|
设计模式 算法 PHP
深入理解PHP中的数组操作探索编程之美:从代码到架构的思维转变
【8月更文挑战第24天】在PHP编程中,数组是基础且强大的数据结构。本文将通过浅显易懂的方式,介绍如何在PHP中高效地操作数组,包括创建、遍历、排序和过滤等常见任务。无论你是初学者还是有经验的开发者,这篇文章都会带给你新的启示。 【8月更文挑战第24天】在编程的世界中,代码不仅仅是冰冷的字符排列,它承载着思想、解决问题的智慧和创新的灵魂。本文将通过个人的技术感悟,带领读者从编写单一功能的代码片段出发,逐步深入到整个软件架构的设计哲学,探索如何将代码块转化为高效、可维护和可扩展的系统。我们将一起见证,当代码与架构思维相结合时,如何引发技术实践的革命性飞跃。
|
3月前
|
存储 负载均衡 数据库
探索后端技术:从服务器架构到数据库优化的实践之旅
在当今数字化时代,后端技术作为支撑网站和应用运行的核心,扮演着至关重要的角色。本文将带领读者深入后端技术的两大关键领域——服务器架构和数据库优化,通过实践案例揭示其背后的原理与技巧。无论是对于初学者还是经验丰富的开发者,这篇文章都将提供宝贵的见解和实用的知识,帮助读者在后端开发的道路上更进一步。