Struts2 在struts 2应用程序中创建两个或多个sitemesh装饰器?
我正在使用sitemesh 2.4插件创建struts 2应用程序,我想根据请求的资源应用多个decorator decorators.xmlStruts2 在struts 2应用程序中创建两个或多个sitemesh装饰器?,struts2,decorator,sitemesh,Struts2,Decorator,Sitemesh,我正在使用sitemesh 2.4插件创建struts 2应用程序,我想根据请求的资源应用多个decorator decorators.xml <?xml version="1.0" encoding="UTF-8"?> <decorators defaultdir="/decorators"> <decorator name="layout1" page="layout1.jsp"> <pattern>/first/*</patte
<?xml version="1.0" encoding="UTF-8"?>
<decorators defaultdir="/decorators">
<decorator name="layout1" page="layout1.jsp">
<pattern>/first/*</pattern>
</decorator>
<decorator name="layout" page="layout.jsp">
<pattern>/second/*</pattern>
</decorator>
</decorators>
/首先/*
/第二/*
我在decorators目录中创建了两个不同的布局文件layout.jsp和layout1.jsp,并创建了一个如下所示的导航文件
<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %>
<decorator:usePage id="thePage" />
<html>
<head>
</head>
<body>
<% String selection = thePage.getProperty("meta.selection"); %>
<p>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<% if(selection != null && "index".equals(selection)){ %>
<a href="first/index.jsp" class="selected">Main</a>
<%System.out.println(""+selection); %>
<% } else { %>
<a href="first/index.jsp">Main</a>
<%System.out.println("index else"+selection); %>
<% } %>
</td>
</tr><tr>
<td>
<% if(selection != null && "page1".equals(selection)){ %>
<a href="second/page1.jsp" class="selected">Page 1</a>
<% } else { %>
<a href="second/page1.jsp">Page 1</a>
<% } %>
</td>
</tr>
</table>
欢迎页面(/first/index.jsp)用layout1装饰器显示,当我单击“page 1”链接时,它也会用相应的(layout)装饰器显示。但问题是,当访问“第1页”后单击主链接时,它给出了“HTTP Status 404-/StrutsSitemesh/second/first/index.jsp”,它将请求的资源与以前的资源目录附加在一起。请帮助我使其工作我在每个链接中使用reqest.getContextPath()方法,这些链接返回应用程序的上下文路径,并请求具有如下绝对路径的资源----
如果你们有更高效的解决方案,请详细说明
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<% if(selection != null && "index".equals(selection)){ %>
<a href="<%=request.getContextPath() %>/first/index.jsp
class="selected">Main</a>
<%System.out.println(""+selection); %>
<% } else { %>
<a href="<%=request.getContextPath() %>/first/index.jsp">Main</a>
<%System.out.println("index else"+selection); %>
<% } %>
</td>
</tr>
<tr>
<td>
<% if(selection != null && "page1".equals(selection)){ %>
<a href="<%=request.getContextPath() %>/second/page1.jsp"
class="selected">Page 1</a>
<% } else { %>
<a href="<%=request.getContextPath() %>/second/page1.jsp">Page 1</a>
<% } %>
</td>
</tr>
</table>