zoukankan      html  css  js  c++  java
  • 大二下学期学习进度(十六)

    编程时长:14h

    代码行数:760行

    发表博客篇数:3

    所学知识点:

    1.之前做WEB项目的时候显示内容一直用的当初学长的代码思路,将实体放进LIST集合,存进session,在JSP页面中用foreach来循环遍历出来,但是由于调整TOMCAT将jstl包搞坏,严重: Servlet.service() for servlet [jsp] in context with path [/图书管理系统] threw exception [The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application] with root cause
    org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application一直出现这样的报错,查询百度了很长一段时间还未解决,于是通过结对开发我学到一个新的显示内容的方法,

    public ResultSet getAllRs(){
       		String sql="SELECT * from photo1 ORDER BY xuhao desc";
       		Connection conn = db.getConn();
       		ResultSet rs = null;
       		try{
    			 Statement state = conn.createStatement();
    			 rs=state.executeQuery(sql);
    		}
    		catch(SQLException e){
    			e.printStackTrace();
    			}
    		return rs;
    	}
    

      通过返回一个ResulSet结果集,在jsp页面直接输出结果

     <%
          
            ResultSet rs=dao.getAllRs();
            if(rs==null){
          %>
          <tr align="center" valign="middle"><td colspan="4">没有记录显示!</td>
          </tr>
          <%
            }
            else{
            	 if(rs.next()){
          %>
          <tr align="center" valign="middle" height="22">
            <td>222222</td>  	
            <td><%=rs.getString("id") %></td>  		 
            <td><img src="upload<%=rs.getString("name") %>" width="150px";height="100px"></td>                 	
          </tr>
          <%
            	}
            	 
    

     

  • 相关阅读:
    php 计算时间添加
    微信网页授权
    微信抢红包微信 PHP代码实现
    微信中禁止长按复制的代码
    【转】java内存分配和String类型的深度解析
    【转】java中创建对象的方法
    【转】深入理解Java的接口和抽象类
    【转】Java 字节流与字符流的区别
    【转】Java并发编程:Thread类的使用
    【转】深入理解java异常处理机制
  • 原文地址:https://www.cnblogs.com/zjl-0217/p/11069803.html
Copyright © 2011-2022 走看看