display tag with struts2

♀尐吖头ヾ 提交于 2019-12-02 20:06:48

问题


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:


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>


来源:https://stackoverflow.com/questions/7359100/display-tag-with-struts2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!