struts2 - Creating two or more sitemesh decorators in struts 2 app? -


i creatig struts 2 application using sitemesh 2.4 plugin in want apply multiple decorator acording requested resource.

decorators.xml

<?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> 

i have created 2 different layout file named layout.jsp , layout1.jsp inside decorators directory , have create navigation file this

<%@ 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>  


welcome page(/first/index.jsp) displayed layout1 decorator , when click on "page 1" link display corresponding(layout) decorator. problem when click on main link after visiting "page 1" gives "http status 404 - /strutssitemesh/second/first/index.jsp" it's appending requested resource previous resource directory. plz me working

i using reqest.getcontextpath() method inside every link return context path of application , request resource absolute path this----

<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>  

if people have more productive , effective solution please elaborate.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -