display tag with struts2

2019-03-06 04:08发布

I am trying to use display tag for my ArrayList passed from action class.

Action Class

public List<AccessLog> getAccessLogList() throws ParseException
    {

        AccessLogManager am = new AccessLogManager(Config.getInstance());
        ArrayList<AccessLog> accessLogList = new ArrayList<AccessLog>();

        accessLogList = am.getAccessLog(userId, actionId, searchStartDate, searchEndDate);
        HttpSession sessAccessLog = req.getSession();
        sessAccessLog.setAttribute("accessLogListSession", accessLogList);
        return accessLogList;
    }

JSP Page

     <display:table id="accessLogList" name="accessLogList" requestURI="SessionLogAction" pagesize="10" defaultsort="1" >
        <display:column property="accessLogId" title="LogId" sortable="true" headerClass="sortable" />
        <display:column property="username" title="Username" sortable="true" headerClass="sortable"/>
        <display:column property="actionName" title="Action" sortable="true" headerClass="sortable"/>
        <display:column property="description" title="Description" sortable="true"  headerClass="sortable"/>
        <display:column property="remark" title="Remark"/>
        <display:column property="timeStamp" title="TimeStamp" sortable="true" headerClass="sortable"/>
    </display:table>

Although I can see the first page in HTML, all the pagelinks (such as 2,3,etc..) are not working. So I am trying to pass the arraylist value in Session. But I am facing new error again.

My question is How can I make the page links to work in Display Tag with struts2. I found example with struts1, but not with struts2. Thanks in advance.

1条回答
相关推荐>>
2楼-- · 2019-03-06 04:27

finally I fixed it.

display:table id="accessLogList" name="accessLogList" requestURI="viewLogList.action" pagesize="10" defaultsort="1">

Please use the action name that will be map to the specific action. It works perfectly.

for example:

<action name="viewLogList" 
                class="test.SessionLogAction">
                <result name="success">/WEB-INF/pages/Log_list.jsp</result>
                <result name="input">/WEB-INF/pages/Log_list.jsp</result>
        </action>
查看更多
登录 后发表回答