使用sitemesh建立复合视图 - 1.hello
使用sitemesh建立复合视图 - 2.装饰器
使用sitemesh建立复合视图 - 3.其它讨论 <- now
前面的文章已经足以应用sitemesh来改善您的应用,但我发现还有一些其他的东东可能也会对大家有所帮助
可打印的界面装饰 |
前面说过有1种可打印的装饰器,可以允许你当用http://localhost/aaa/a.html?printable=true方式访问时,应用其他的装饰器(自己指定),给出原始页面以供打印(免得把header,footer等的花哨的图片也搭上)。
让我们来看一看怎样实现他:
1.首先在WEB-INFO/sitemesh.xml中设置: <mapper class="com.opensymphony.module.sitemesh.mapper.PrintableDecoratorMapper"> <param name="decorator" value="printable" /> <param name="parameter.name" value="printable" /> <param name="parameter.value" value="true" /> </mapper> 这样就可以通过?printable=true来使用名为printable的装饰器,而不是用原来的装饰器。
2.在WEB-INFO/decorators.xml中定义相应的printable装饰器 <decorator name="printable" page="printable.jsp"/>
3.最后编写printable装饰器/decorators/printable.jsp
<%@ taglib uri="sitemesh-decorator" prefix="decorator" %> <html> <head> <title><decorator:title /></title> <decorator:head /> </head> <body>
<h1><decorator:title /></h1> <p align="right"><i>(printable version)</i></p>
<decorator:body />
</body> </html> |
这样就可以让一个原始页面通过?printable=true开关来切换不同的装饰器页面。
|
中文问题 |
由于sitemesh内部所使用的缺省字符集为iso-8859-1,直接使用会产生乱码,我们可以通过以下方法纠正之:
-
方法1:可以在您所用的application server的配置文件中找一找,有没有设置encoding或
charset的项目,然后设成gbk或gb2312即可
-
方法2:这也是我们一直使用的方法。 1.在每一个jsp页里设置: <%@ page contentType="text/html; charset=gbk"%> 来告诉server你所要求的字符集。 2.在每个jsp页的head中定义:<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=gbk"> 来告诉浏览器你所用的字符集。
|
总结:使用sitemesh最通常的途径: |
1.配置好环境,
2.在WEB-INFO/decroators.xml中描述你将建立的包装器。
3.开发在decroators.xml中描述的包装器,最好存放在/_decorators目录下
4.ok ,可以看看辛勤的成果了 :)
|
资源:
关于作者:
陈鹏,西安东软公司。作为一名狂热的程序员希望每一天都能成长进步,并希望与大家分享快乐和知识。
请用以下方式和他联系:email chen56@msn.com
分享到:
相关推荐
sitemesh-3.0-alpha-2.jar
struts2-sitemesh-plugin-2.1.8.1.jar
struts2-sitemesh-plugin-2.0.8.jar
sitemesh-2.4.2-src.jar 是sitemesh的源文件jar包,当调试时需要选择该jar包进行资源查找,很好用的页面架构工具
sitemesh-2.2.1.jarsitemesh-2.2.1.jarsitemesh-2.2.1.jar
struts2-sitemesh-plugin-2.2.1.1.jarstruts2
sitemesh-2.4.1.jar sitemesh-2.4.1.jar sitemesh-2.4.1.jar sitemesh-2.4.1.jar sitemesh-2.4.1.jar sitemesh-2.4.1.jar
sitemesh-2.2.1.jar
用于在SSH2工程中使用sitemesh-2.4.jar 包;
struts2-sitemesh-plugin-2.1.6.jar
commons-lang3-3.2.jar, commons-logging-1.1.3.jar, commons-validator-1.3.1.jar, core-0.6.2.jar, dwr-1.1.1.jar, ezmorph-1.0.6.jar, freemarker-2.3.22.jar, google-collections-1.0.jar, google-gxp-0.2.4-...
包含struts2-core-2.5.10.1.jar,struts2-jfreechart-...struts2-sitemesh-plugin-2.5.10.1.jar,struts2-spring-plugin-2.5.10.1.jar,struts2-testng-plugin-2.5.10.1.jarstruts2-tiles-plugin-2.5.10.1.jar等jar包
SiteMesh (http://www.opensymphony.com/sitemesh/). XWork (http://www.opensymphony.com/xwork/). XPP3 (http://www.extreme.indiana.edu/xgws/xsoap/xpp/). XStream (http://xstream.codehaus.org/).
sitemesh-2.2.1.rar sitemesh-2.2.1.rar sitemesh-2.2.1.rar
SiteMesh is a web-page layout and decoration framework and web- application integration framework to aid in creating sites consisting of many pages for which a consistent look/feel, navigation and ...
sitemesh-2.3.jar
struts框架与sitemesh框架整合的插件,在java web开发中可以制作模板页,使自己做的网站看起来更专业
最近温习ssh2整合编程,顺便浏览下struts2有什么更新的消息,下载了新版本的struts2的2.1.8.1版,使用的是MyEclipse8.0开发,但是问题就随之而来了。MyEclipse8.0中自带的struts2版本是2.1.6,spring版本有2.0,2.5...
commons-lang3-3.4.jar, commons-logging-1.1.3.jar, dwr-1.1.1.jar, ezmorph-1.0.6.jar, freemarker-2.3.23.jar, google-collections-1.0.jar, google-gxp-0.2.4-beta.jar, hamcrest-core-1.3.jar, jackson-...
解决 java.lang.NoSuchFieldException: DEFAULT_PARAM>问题,下载后替换即可。