如何解决从 Tiles2 迁移到 Tiles 3 时如何在瓷砖定义标签中添加 bean 列表
我们在 Tiles2 中有应用程序,其中我们有在 put-list-attribute 中有 bean 的tile 定义标签并且运行良好,但无法迁移那些与 Tiles 3 兼容的标签。 谁能指导我们,
示例代码...
<definition name=".tabs.resource.list" extends=".tabs.resource">
<put-attribute name="selectedIndex" value="0" />
<put-attribute name="resourceType" value="1" />
<put-list-attribute name="tabList">
<bean classtype="org.test.sample.ui.util.Tab">
<set-property property="value" value="Tab1" />
<set-property property="link" value="currentHealthTab1listVisibility.action" />
<set-property property="mode" value="currentHealth" />
<set-property property="height" value="21" />
<set-property property="width" value="102" />
</bean>
<bean classtype="org.test.sample.ui.util.Tab">
<set-property property="value" value="Tab2" />
<set-property property="link" value="viewlistTab2listVisibility.action" />
<set-property property="mode" value="view" />
<set-property property="height" value="21" />
<set-property property="width" value="102" />
</bean>
</put-list-attribute>
</definition>`
org.test.sample.ui.util.Tab 被 simplemenuitem 类覆盖
解决方法
由于在最新版本的磁贴中删除了菜单项的 bean,我们将不得不创建 servlet 类并映射到使用这些属性的 jsp 页面{在上面的问题中,jsp 指向了 extends=".tabs.resource" /在 web.xml 中定义}.jsp 页面 并在类中设置属性 我们可以设置 list 属性并包含 servlet 响应,如下所示:
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.test.sample.ui.util.Tab;
public class ControlTabNG extends HttpServlet{
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws IOException{
List<Tab> ControlTabNGtablist = new ArrayList<Tab>();
Tab ObjTab1 = new Tab();
ObjTab1.setValue("Tab1");
ObjTab1.setLink("viewlistTab1listVisibility.action");
ObjTab1.setMode("View");
ObjTab1.setHeight(21);
ObjTab1.setWidth(101);
Tab ObjTab2 = new Tab();
ObjTab2.setValue("Tab2");
ObjTab2.setLink("viewlistTab2listVisibility.action");
ObjTab2.setMode("View");
ObjTab2.setHeight(21);
ObjTab2.setWidth(101);
ControlTabNGtablist.add(ObjTab1);
ControlTabNGtablist.add(ObjTab2);
request.setAttribute("tabList",ControlTabNGtablist);
try {
RequestDispatcher rd=request.getRequestDispatcher("/simplemenuitem/SampleTabNG.jsp");
rd.include( request,response);
} catch (ServletException e) {
e.printStackTrace();
}
`
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。