Web templating (struts tiles) - best solution to indicate current page?
I would like to indicate the currently chosen page in a shared menu component of a web page in a Struts Tiles project.
I can think of some possible solutions
- check current URL
- call some Javascript to indicate
- possibly hooked into the tiles or struts config files and开发者_如何学Python read.
I'm sure this problem has been faced many times before. What is the best way of dealing with this?
Did you consider using struts-menu? It integrates nicely with Tiles if I remember well.
I used the following method:
tiles-des.xml
<definition name=".basic.layout" path="/WEB-INF/jsps/basicLayout.jsp">
<put name="title" value=""/>
<put name="homeMenuClass" value=""/>
<put name="forumMenuClass" value=""/>
<put name="helpMenuClass" value=""/>
</definition>
And in the same file set the appropriate menu class to "active" for differing tiles.
basicLayout.jsp
<li class="<tiles:getAsString name="homeMenuClass"/>">...
<li class="<tiles:getAsString name="forumMenuClass"/>">...
<li class="<tiles:getAsString name="helpMenuClass"/>">...
精彩评论