我是Struts的初学者并且有所怀疑。我有一个页面,将其重定向到.do文件,该文件又调用struts页面。
上面的页面转发调用下面指定的页面:
<display:table name="sessionScope.LocationLoadActionForm.loadList" class="dataTable" style="width:101%;" id="row"
pagesize="5" cellspacing="0">
<display:column title="<input type='checkbox' name='selectall' id='selectall' value='all'/>">
<html:checkbox styleClass="case" name="LocationLoadActionForm" property="id" value="${row.locid}"/>
</display:column>
<display:column property="locid" title="Location ID" media="html" />
<display:column property="locname" title="Location Name" group="1" sortable="true"/>
<display:column property="loc_city" title="Location City" group="2" sortable="true" />
<display:setProperty name="paging.banner.full">
<div class="pagelinks" align="right"> [<a href="{1}">First</a>/ <a href="{2}">Prev</a>] {0} [ <a href="{3}">Next</a>/ <a href="{4}">Last </a>]</div>
</display:setProperty>
<display:setProperty name="paging.banner.first">
<div class="pagelinks" align="right"> [First/Prev] {0} [ <a href="{3}">Next</a>/ <a href="{4}">Last</a>] </div>
</display:setProperty>
<display:setProperty name="paging.banner.last">
<div class="pagelinks" align="right">[ <a href="{1}">First</a>/ <a href="{2}">Prev</a>] {0} [Next/Last] </div>
</display:setProperty>
<display:setProperty name="paging.banner.onepage">
<div class="pagelinks" align="right"> {0} </div>
</display:setProperty>
<display:setProperty name="paging.banner.all_items_found" value="" />
<display:setProperty name="paging.banner.some_items_found" value="" />
<display:setProperty name="paging.banner.one_item_found" value="" />
</display:table>
现在有一个按钮可以重定向到删除页面并将其转发到Locationload.do。现在,当我执行删除操作时,虽然我的记录已从数据库中删除,但displaytag显示旧值。如何解决问题。
struts配置文件的详细信息如下:
<form-bean name="LocationDetailAddActionForm" type="Location.LocationDetailAddActionForm"/>
<form-bean name="LocationLoadActionForm" type="Location.LocationLoadActionForm"/>
<form-bean name="CountryActionForm" type="Country.CountryActionForm"/>
<form-bean name="LocationActionForm" type="Location.LocationActionForm"/>
<form-bean name="OrganizationActionForm" type="Organization.OrganizationActionForm"/>
</form-beans>
<global-exceptions>
</global-exceptions>
<action-mappings>
<action input="/" name="OrganizationActionForm" path="/addOrganizationGeneral" scope="session" type="Organization.OrganizationAction">
<forward name="success" path="/Administrator/OrganizationDetail.jsp"/>
</action>
<action input="/" name="CountryActionForm" path="/addCountry" scope="session" type="Country.CountryAction">
<forward name="success" path="/Administrator/Country.jsp"/>
<forward name="validate" path="/Administrator/Country_validate.jsp"/>
</action>
<action input="/" name="LocationActionForm" path="/addLocation" scope="session" type="Location.LocationAction">
<forward name="success" path="/Administrator/AdminLocation/LocationDetail.jsp"/>
</action>
<action input="/" name="LocationLoadActionForm" path="/LocationLoad" scope="session" type="Location.LocationLoadAction">
<forward name="success" path="/Administrator/AdminLocation/LocationDetail.jsp"/>
</action>
<action input="/" name="LocationDetailAddActionForm" path="/LocationAdd" scope="session" type="Location.LocationDetailAddAction">
<forward name="success" path="/Administrator/AdminLocation/Location.jsp"/>
</action>
<action input="/" name="LocationLoadActionForm" path="/LocationDelete" scope="session" type="Location.LocationDeleteAction">
<forward name="success" path="/Administrator/AdminLocation/LocationDelete.jsp"/>
</action>
</action-mappings>
答案 0 :(得分:1)
显示标记显示您告诉它显示的值列表。如果值为dsplayed,则表示它仍在列表中。也许您从数据库中删除了该项,但忘记将其从会话中存储的列表中删除并显示在表中:
sessionScope.LocationLoadActionForm.loadList
会话应该用于存储具有会话生命周期的对象(用户名,购物车等)如果您使用请求存储要在表中显示的数据列表,那么您将浪费减少内存,并且不会像现在这样冒险显示陈旧的值。默认情况下,Struts选择使用会话范围的动作表单,这是一个非常糟糕的选择。确保默认使用请求范围的表单bean。