In the JSP, read the contents of the database table as a table and add hyperlinks to the table:
1<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "2pageencoding= "UTF-8"%>3<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >4<%@ pageImport= "Java.io.*,java.util.*,java.sql.*"%>56<title> View Jobs </title>7<style type= "Text/css" >8 a:link {color:blue;}9 a:visited {color:blue;}Ten a:hover {color:red;} One</style> A -<table border= "1" width= "80%" align= "Center" > -<tr> the<TD width= "Ten" valign= "Top" ><div align= "center" > Numbering </div></td> -<TD width= "valign=" Top "><div align=" Center "> class </div></td> -<TD width= "valign=" Top "><div align=" center "> Job Content </div></td> -<TD width= "Ten" valign= "Top" ><div align= "center" > Activity Accessories </div></td> +</tr> -<% +Request.setcharacterencoding ("UTF-8"); AJava.sql.Connection conn = drivermanager.getconnection ("Jdbc:mysql://localhost:3306/login", "root", "123456"); atString sql1= "Select*from homework"; -Statement statemenet =(Statement) conn.createstatement (); -ResultSet rs1 =statemenet.executequery (SQL1); - while(Rs1.next ()) { -%> -<tr> in<TD width= "Ten" ><div align= "center" > <%=rs1.getstring ("number")%></div></td> -<TD width= "Ten" ><div align= "center" > <%=rs1.getstring ("Class")%></div></td> to<TD width= "Ten" ><div align= "center" > <%=rs1.getstring ("Job content")%></div></td> +<TD width= "5" ><div align= "center" ><a href= "download_stu.jsp" style= "Text-decoration:none" > Downloads < /a></div></td> -</tr> the *<% $ } rs1.close (); Panax Notoginseng%> -</table>
The tables built with Navicat premium in the database are:
The result of the above program operation is:
Read database contents in JSP (i)