0

我们在 Tiles2 中有应用程序,其中我们在 put-list-attribute 中有具有 bean 的切片定义标记并且运行良好,但无法迁移与 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 类

4

1 回答 1

0

由于在最新版本的图块中删除了菜单项的 bean,我们将不得不创建 servlet 类并使用这些属性映射到 jsp 页面{在上面的问题中,其中 jsp 指向 extends=".tabs.resource" / jsp 页面web.xml 中的定义} 并在类中设置属性,我们可以设置列表属性并包含 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();   
}

`

于 2021-03-03T09:29:11.877 回答