📄 news.jsp
字号:
<html>
<head>
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page language="java" import="java.sql.*"%>
<jsp:useBean id="sqlbean" scope="page" class="news.sql_data"/>
<title>发布页面</title>
</head>
<body>
<div align="center"><br>
<br>
<font color="#000000" size="6"><strong>新闻发布</strong></font><font
color="#000000"><br>
</font> </div>
<%
String sql,d,news,title;
ResultSet rsclass=sqlbean.executeQuery("select * from class");
%>
<table width="69%" align="center">
<tr>
<td>
<table width="100%">
<%
String tempclass1=(String)show_data_class_return(out,rsclass,1);
sql="select * from news where class= '"+tempclass1+"'";
ResultSet rstitle1=sqlbean.executeQuery(sql);
show_title(out,rstitle1,1);
out.print("<tr><td align='center'><a href='new2.jsp?class=");
out.print(tempclass1);
out.print("'>更多</a></tr></td>");
%>
</table>
</td>
<td>
<table width="100%">
<%String tempclass2=(String)show_data_class_return(out,rsclass,2);
sql="select * from news where class= '"+tempclass2+"'";
ResultSet rstitle2=sqlbean.executeQuery(sql);
show_title(out,rstitle2,1);
out.print("<tr><td align='center'><a href='new2.jsp?class=");
out.print(tempclass2);
out.print("'>更多</a></tr></td>");
%>
</table>
</td>
</tr>
<tr>
<td>
<table width="100%">
<%String tempclass3=(String)show_data_class_return(out,rsclass,3);
sql="select * from news where class= '"+tempclass3+"'";
ResultSet rstitle3=sqlbean.executeQuery(sql);
show_title(out,rstitle3,1);
out.print("<tr><td align='center'><a href='new2.jsp?class=");
out.print(tempclass3);
out.print("'>更多</a></tr></td>");
%>
</table></td>
<td>
<table width="100%">
<%String tempclass4=(String)show_data_class_return(out,rsclass,4);
sql="select * from news where class= '"+tempclass4+"'";
ResultSet rstitle4=sqlbean.executeQuery(sql);
show_title(out,rstitle4,1);
out.print("<tr><td align='center'><a href='new2.jsp?class=");
out.print(tempclass4);
out.print("'>更多</a></tr></td>");
%>
</table></td>
</tr>
<tr>
<td>
<table width="100%">
<%String tempclass5=(String)show_data_class_return(out,rsclass,5);
sql="select * from news where class= '"+tempclass5+"'";
ResultSet rstitle5=sqlbean.executeQuery(sql);
show_title(out,rstitle5,1);
out.print("<tr><td align='center'><a href='new2.jsp?class=");
out.print(tempclass5);
out.print("'>更多</a></tr></td>");
%>
</table></td>
<td>123123</td>
</tr>
</table>
<!--以下函数用于显示 -->
<%!String show_data_class_return(JspWriter out,ResultSet rs,int x)
throws SQLException,IOException{
rs.absolute(x);
String tempclass=(String)rs.getString(1);
out.print("<tr><td align='center'><font size='4'><b>");
out.print(tempclass);
out.print("</b></font></td></tr>");
return tempclass;
}
%>
<%!void show_title(JspWriter out,ResultSet rs,int x)
throws SQLException,IOException{
int i,j;
rs.absolute(x);
for(i=x,j=6;x<j;x++)
{
rs.relative(1);
out.print("<tr><td>");
out.print("<b>* </b>");
out.print("<font size='3'><a href='newscontext.jsp?title=");
out.print(rs.getString("title"));
out.print("'>");
out.print(rs.getString("title"));
out.print("</a></font> ");
out.print("<font size='2'>"+rs.getString("d")+"</font>");
out.print("</td></tr>");
}
rs.close();
}
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -