0

我在struts中将显示标签应用于我的jsp但无法做到,请查看

1.strutsconfig

<form-beans><form-bean name="DailysheetForm" type="com.myapp.struts.DailysheetForm"/>
</formbean>
<action input="/" path="/DailysheetList" name="DailysheetForm"  scope="request"            type="com.myapp.struts.DialysheetListAction">
   <forward name="success" path="/DailysheetList.jsp"/>
</action>

2.表格

public class DailysheetForm extends ActionForm 
 {
// some getter and setter methods i used like receiptno
   protected ArrayList arraylist;
   public ArrayList getArraylist()
     {
       return arraylist;
     }

public void setArraylist(ArrayList arraylist) {

    this.arraylist = arraylist;

}

3.动作类

public ActionForward execute(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {

    ArrayList dailysheetdata;
    DailysheetForm dailyform = (DailysheetForm) form;
    Class.forName("com.mysql.jdbc.Driver");
    Connection connect = DriverManager.getConnection("jdbc:mysql://localhost/Stonecrusher?"
                        + "user=Stonecrusher&password=xxxxxx");
    System.out.println("Connection"+connect);
    dailysheetdata = StoneCrusherData.getDailysheetData(connect);

    dailyform.setArraylist(dailysheetdata) ;
    return mapping.findForward(SUCCESS);
     }

JSP

<display:table id="data"  name="requestScope.DailysheetForm.arraylist"requestURI="/DailysheetList" pagesize="10" >
  <display:column property="receiptno" title="RECEIPTNO" sortable="true"/>
  <display:column property="cutomername" title="CUSTOMER NAME" sortable="true"/>
</display:table>
<display:table id="data" name="requestScope.DailysheetForm.arraylist" requestURI="/DailysheetList" pagesize="10" >
  <display:column property="receiptno" title="RECEIPTNO" sortable="true"/>
  <display:column property="cutomername" title="CUSTOMER NAME" sortable="true"/>
</display:table>

它不起作用,基本上我正在将数据获取到 dailysheetdate,它是我的 Action 类中的数组列表,我想在带有分页的 jsp 中显示它。我知道我错了,请帮助我怎么做。

4

1 回答 1

1

检查您的 jar 文件是否将所有必需的 jar 放入 lib 中。. 仍然有问题将您的错误粘贴到此处..

请参阅显示标签教程

那么你不需要在in 中指定inputname属性<action>strutsconfig.xml

即你的代码应该像这样

<action path="/DailysheetList" scope="request"  type="com.myapp.struts.DialysheetListAction">
   <forward name="success" path="/DailysheetList.jsp"/>
</action>

那么肯定会执行Action Class..

还有一件事是通过查看您的操作类代码,我不知道是否StoneCrusherData创建了对象..也请检查以下行

dailysheetdata = StoneCrusherData.getDailysheetData(connect);
于 2012-07-07T11:06:31.400 回答