日期:2014-05-17  浏览次数:20809 次

求助:struts1.2的action方法运行没有结果!另求(配置连接池)
RT,同一个action类里其他的方法都可以,唯独这一个运行页面没有结果,程序不报错,不知道哪里没写对,求指导。
代码:

Java code
public ActionForward showall(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
    {
        NewsForm AllNewsActionForm=(NewsForm)form;
        try
        {
            ActionNews actionNews = new ActionNews(AllNewsActionForm);
            List<String[]>result=actionNews.search();
            if(result.size()>0)
            {
                request.setAttribute("result",result);
                request.setAttribute("info_all", "总记录数:" + String.valueOf(result.size()));
            }
            else  
                request.setAttribute("info_all", "没有符合要求的记录!");

            }
        catch(Exception e)
        {
            request.setAttribute("info_all",e.getMessage());            
        }
        return mapping.findForward("searchAll");
    }



具体操作方法代码:

Java code
public List<String[]>search() throws Exception
 {
     List<String[]> result = new LinkedList<String[]>();
     String sql="select * from s_news";
     PreparedStatement pstmt= conn.prepareStatement(sql);
     ResultSet rs =pstmt.executeQuery();
     while(rs.next())
     {
         String[] row=new String[6];
           row[0] = rs.getString(1);
           row[1] = rs.getString(2);
           row[2] = rs.getString(3);
           row[3] = rs.getString(4);
           row[4] = rs.getString(5);
           row[5] = rs.getString(6);
           result.add(row);
     }
     rs.close();
     conn.close();
     return result;
 }



jsp:
HTML code
<c:set var="result" value="${requestScope.result}" />
       <table width="100%">
            <tr align="center">
                <td>
                     ${requestScope.info_all}
                </td>
            </tr>
            <tr align="center">
                <td>
                <logic:present name="result">
                 <table border="1">
                              <tr align="center">
           <td> 编号 <input type="hidden" name="news_detail" value="${row[4]}"></td>
                                  <td> 主题 </td>
                                  <td> 作者</td>
                                  <td> 日期</td>
                                  <td align="center" colspan=4>操作</td>
                              </tr>    
            <logic:iterate id="row" name="result">
                          <tr align="center">
                    <td> ${row[0]} </td>
                    <td> ${row[1]} </td>
                     <td> ${row[2]} </td>
                    <td> ${row[3]}</td>                                       
                           </tr>
                              </logic:iterate>
                              </table>
                              </logic:present>
                              </td>                                          
            </tr>
        </table>



xml:

Java code

                    香港云服务器 免备案 云主机VPS 国内 独立IP 独享15M 月付SSD