开发者

spring mvc - easiest way to check on what page you are and change style of the menu items

I'm working on a spring mvc project. 开发者_开发百科I need to change the style of my menu items when I'm on a particular page. The css is done. But i still need a way to check on which page I am.

What is the easiest way to do this. All solutions are appreciated.

, thank you


You can integrate Apache Tiles into your Spring MVC project (exmple here) and pass path to css needed in tiles.xml.

Alternatively you can send this path to your JSP page in JavaBean, but it is less declarative and requires accurate manipulating of beans.


Try this short cut.

Set the style's class name in the ModelAndView as a variable. In the JSP files directly use the variable as the style's class name.

In the controller

modelAndView.add("styleVariableName","styleToBeApplied")

In the JSP

<div class="${styleVariableName}">

styleToBeApplied should be a css class and you can repeat this for every controller action.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜