appfuse中web.xml的css样式配置说明:
1 <!-- Define the default CSS Theme --> 2 <context-param> 3 <param-name>theme</param-name> 4 <param-value>simplicity</param-value> 5 </context-param>
该段用于页面整体风格,appfuse对这个参数的使用如下:
- 在/myapp/src/web/org/appfuse/webapp/listener/StartupListener.java文件中将theme值放入ServletContext
- 在/myapp/src/web/org/appfuse/webapp/filter/LocaleFilter.java文件中将request中的theme值保存到ServletContext
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 ServletContext context = event.getServletContext(); 2 3 // Orion starts Servlets before Listeners, so check if the config 4 // object already exists 5 Map config = (HashMap) context.getAttribute(Constants.CONFIG); 6 7 if (config == null) { 8 config = new HashMap(); 9 } 10 11 if (context.getInitParameter("theme") != null) { 12 config.put("theme", context.getInitParameter("theme")); 13 }
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 String theme = request.getParameter("theme"); 2 if (theme != null && request.isUserInRole(Constants.ADMIN_ROLE)) { 3 Map config = (Map) getServletContext().getAttribute(Constants.CONFIG); 4 config.put("theme", theme); 5 }
- 页面根据theme值加载css文件
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 <link rel="stylesheet" type="text/css" media="all" href="<c:url value='/styles/${appConfig["theme"]}/theme.css'/>" /> 2 <link rel="stylesheet" type="text/css" media="print" href="<c:url value='/styles/${appConfig["theme"]}/print.css'/>" />