JavaWEB查询数据库信息(JSTL)
来源:互联网 发布:斯凯奇淘宝旗舰店真假 编辑:程序博客网 时间:2024/05/16 16:13
1、Servlet源代码
实现数据库查询,并将数据封装到javabean中,将封装的数据添加到request作用域中,然后用JSTL标签遍历request作用域,实现数据查询操作。
注:javabean中封装的数据属性名要和数据库表中的列明相同,不然查询为空。
import java.io.IOException;import java.util.List;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import dataBean.ProductInfoBean;import dataDAO.SearchData;public class SearchInfoServlet extends HttpServlet {/** * 以批号、id号、是否合格为条件,对数据库进行查询,将结果集封装到List<ProductInfoBean>,通过session存储查询返回的数据,页面转发到查询页。 * * */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//获取jsp页面提交的搜索参数 String searchbatch=new String(request.getParameter("searchBatch").getBytes("iso-8859-1"),"utf-8"); String searchid=new String(request.getParameter("searchId").getBytes("iso-8859-1"),"utf-8"); String testresult=new String(request.getParameter("testResult").getBytes("iso-8859-1"),"utf-8"); try{ ProductInfoBean probean=new ProductInfoBean(); probean.setBatch_Number(searchbatch); probean.setTestid(searchid); probean.setResult(testresult); List<ProductInfoBean> list= SearchData.SearchBatchNumber(probean); request.setAttribute("list", list); request.getRequestDispatcher("/Search.jsp").forward(request, response); }catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request,response); }}
2、JSP页面代码(JSTL标签)
0 0
- JavaWEB查询数据库信息(JSTL)
- JavaWeb---JSTL数据库标签
- 用JSTL查询数据库
- JavaWeb JSTL
- JAVAWEB-JSTL
- JavaWeb:JSTL
- Javaweb 将excel文件内信息传入数据库中 并查询
- JSTL标签及显示数据库信息
- JSTL标签及显示数据库信息
- 数据库信息查询
- 查询数据库结构信息
- 查询数据库系统信息
- 查询关于数据库信息
- 遍历数据库查询信息
- 数据库常用信息查询
- Mysql 数据库信息查询
- JDBC查询数据库信息
- 查询数据库信息
- 速算
- Hibernate JPA注解 @Temporal(TemporalType.DATE) 日期注解!
- c++ pcsc
- PDF转换器怎么将PDF转换成Word格式的
- UVALive 6656 Watching the Kangaroo (区间排序 + 二分)
- JavaWEB查询数据库信息(JSTL)
- matlab SVM有监督学习
- ssh反连
- Linux系统信息
- Matlab中画图的说明
- Android Asynchronous Http Client
- 华为oj之求int型正整数在内存中存储时1的个数
- 添加环境变量
- Bluetooth的接收数据测试代码