接下来是一个 actionlist.dopackage com.action;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;import com.ResultGatherPro;public class List extends Action {
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
String sql = "";
String sqlcount = "";
String name = request.getParameter("name");
String ptype = request.getParameter("ptype");
String url = "";
if(name!=null)
{
sql="select top 100 percent * from feature where "+ptype+" like '%"+name+"%'";
sqlcount = "select count(NO) as allrow from ringtable where "+ptype+" like '%"+name+"%'";
url = "&ptype="+ptype+"&name="+name;
}else{
sql="select top 100 percent * from feature order by createtime DESC ";
sqlcount = "select count(NO) as allrow from feature";
}
int pagesize= 15;
int pagenum = 1;
if(request.getParameter("pagenum")!=null)
{
pagenum = java.lang.Integer.parseInt(request.getParameter("pagenum"));
}
ResultGatherPro rs = new ResultGatherPro(sql,pagesize,pagenum,sqlcount);
request.setAttribute("listfeature",rs.selectRS());
request.setAttribute("changepage",rs.ChangePage(request.getRequestURI().substring(request.getRequestURI().lastIndexOf("/")+1),url));
request.setAttribute("gotopage",rs.gotoPage(url));
return mapping.findForward("listfeature");
}}
import javax.servlet.http.HttpServletResponse;import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;import com.ResultGatherPro;public class List extends Action {
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
String sql = "";
String sqlcount = "";
String name = request.getParameter("name");
String ptype = request.getParameter("ptype");
String url = "";
if(name!=null)
{
sql="select top 100 percent * from feature where "+ptype+" like '%"+name+"%'";
sqlcount = "select count(NO) as allrow from ringtable where "+ptype+" like '%"+name+"%'";
url = "&ptype="+ptype+"&name="+name;
}else{
sql="select top 100 percent * from feature order by createtime DESC ";
sqlcount = "select count(NO) as allrow from feature";
}
int pagesize= 15;
int pagenum = 1;
if(request.getParameter("pagenum")!=null)
{
pagenum = java.lang.Integer.parseInt(request.getParameter("pagenum"));
}
ResultGatherPro rs = new ResultGatherPro(sql,pagesize,pagenum,sqlcount);
request.setAttribute("listfeature",rs.selectRS());
request.setAttribute("changepage",rs.ChangePage(request.getRequestURI().substring(request.getRequestURI().lastIndexOf("/")+1),url));
request.setAttribute("gotopage",rs.gotoPage(url));
return mapping.findForward("listfeature");
}}
mapping.findForward("listfeature");对应list.jsp <table width="531" border="0" cellpadding="3" cellspacing="1" bgcolor="#FF99CC" class="font13">
<tr>
<td width="31">编号</td>
<td colspan="2">标题</td>
</tr>
<% list=(List)(request.getAttribute("listfeature")); for(int i=0;i<list.size();i++)
{ %>
<tr bgcolor="#FDE7E1" class="font13">
<td><%=i+1%></td>
<td width="485"><a href="featurecontent.jsp?serial=<%=((Map)list.get(i)).get("NO")%>&name=<%=((Map)list.get(i)).get("title")%>" target="_blank"><%=((Map)list.get(i)).get("title")%>
<% if(!(((Map)list.get(i)).get("pic").toString()).equals("0")) out.print("(图)"); %>
</a> <%=((Map)list.get(i)).get("createtime").toString().substring(0,10)%></td>
</tr>
<%}%>
</table>
<table width="530" height="30" border="0" cellpadding="0" cellspacing="0" class="font14">
<tr>
<td width="530" align="right"><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><%=request.getAttribute("changepage")%></td>
<td><%=request.getAttribute("gotopage")%></td>
</tr>
</table></td>
</tr>
</table>
竟然不知道Tag是什么咚咚
bean:meassage类功能的就很适合用