用struts2显示标签 [英] display tag with struts2
问题描述
我正在尝试为从动作类传递的ArrayList使用display标签。
I am trying to use display tag for my ArrayList passed from 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页面
<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>
虽然我可以看到HTML中的第一页,但所有的页面链接(例如2,3等) ..)不工作。所以我试图在Session中传递arraylist值。但我再次面临新的错误。
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.
我的问题是如何使用struts2使页面链接在显示标记中工作。我找到了使用struts1的示例,但不包含struts2。提前致谢。
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.
推荐答案
最后我修复了它。
display:table id =accessLogListname =accessLogListrequestURI =viewLogList.action
pagesize =10 defaultsort =1>
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.
例如:
<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>
这篇关于用struts2显示标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!