开发者

display tag with struts2

开发者 https://www.devze.com 2023-04-03 13:39 出处:网络
I am trying to use display tag for my ArrayList passed from action class. Action Class public List<AccessLog> getAccessLogList() throws ParseException

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 Sess开发者_开发技巧ion. 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.


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>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号