本小系统采用MyEclipse4.0GA+MySQL5.0+JDK5.0+Tomcat4.0+PowerDesigner12.0开发,为上一篇的续,第一次发,恳请各位指正不足。
1、先改写补充list.jsp增加相应3个按钮,并用JavaScript对相应按钮进行“设置”,code as follows:<o:p></o:p>
<%@ page contentType="text/html;charset=GBK" import="java.util.*,org.riker.news.data.*"%><o:p></o:p>
<o:p> </o:p>
<html><o:p></o:p>
<head><o:p></o:p>
<o:p></o:p>
<title></title><o:p></o:p>
<o:p></o:p>
<jsp:useBean id = "news" scope = "page" class = "org.riker.news.logic.NewsLogicBean"/><o:p></o:p>
<o:p></o:p>
</head><o:p></o:p>
<o:p></o:p>
<body><o:p></o:p>
<o:p></o:p>
<%<o:p></o:p>
String username = (String)session.getAttribute("user");<o:p></o:p>
if(username != null) {<o:p></o:p>
}<o:p></o:p>
%><o:p></o:p>
欢迎您进入本系统:<%=username%><o:p></o:p>
<hr><o:p></o:p>
<form action="insert.jsp" name="form1" method="post"><o:p></o:p>
<center><o:p></o:p>
<table border="1"><o:p></o:p>
<tr><td>序号</td><td>新闻标题</td></tr><o:p></o:p>
<%<o:p></o:p>
String str_curPage = request.getParameter("curPage");<o:p></o:p>
if(str_curPage!=null){<o:p></o:p>
news.setCurPage(Integer.parseInt(str_curPage));<o:p></o:p>
}<o:p></o:p>
List list = news.findAll();<o:p></o:p>
int allRows = news.getAllRows();<o:p></o:p>
int curPage = news.getCurPage();<o:p></o:p>
int rowPerPage = news.getRowPerPage();<o:p></o:p>
int allPage = news.getAllPages();<o:p></o:p>
for(int i=0; i<list.size(); i++) {<o:p></o:p>
NewsDataBean bean = (NewsDataBean)list.get(i);<o:p></o:p>
%><o:p></o:p>
<o:p></o:p>
<tr><td><input type="radio" name="newsid" value="<%=bean.getNewsid()%>"><%=(curPage-1)*rowPerPage+i+1%></td><o:p></o:p>
<td><a href="detail.jsp?newid=<%=bean.getNewsid()%>"><%=bean.getNewstitle()%>(<%=bean.getNewsdate()%>)</td></tr><o:p></o:p>
<%<o:p></o:p>
}<o:p></o:p>
<o:p></o:p>
%><o:p></o:p>
</table><o:p></o:p>
<%<o:p></o:p>
if(curPage!=1) {<o:p></o:p>
%><o:p></o:p>
<a href="/news/main/list.jsp?curPage=1">首页</a><o:p></o:p>
<a href="/news/main/list.jsp?curPage=<%=curPage-1%>">上一页</a><o:p></o:p>
<% }<o:p></o:p>
%><o:p></o:p>
<%<o:p></o:p>
if(curPage!=allPage){<o:p></o:p>
%><o:p></o:p>
<a href="/news/main/list.jsp?curPage=<%=curPage+1%>">下一页</a><o:p></o:p>
<a href="/news/main/list.jsp?curPage=<%=allPage%>">末页</a><o:p></o:p>
<%<o:p></o:p>
}<o:p></o:p>
%><o:p></o:p>
<o:p></o:p>
</center><o:p></o:p>
<hr