`

SiteMesh and Charsets

阅读更多

Platform Defaults

The default character set for SiteMesh is iso-8859-1. SiteMesh currently assumes that the underlying platform encoding is also iso-8859-1.

This can cause some fairly insidious problems if there is a mismatch between the two! Specifically, on platforms which have a different file encoding, this should be overridden. The two known platforms which do not have iso-8859-1 encoding by default are IBM AS/400 JDK's and OSX. The work around in these cases is to specify a -Dfile.encoding=iso-8859-1 parameter as JVM argument when starting the application server.

Using Other Encodings

The iso-8859-1 encoding is sufficient for most European and Western character sets, so nothing will need to be done in this case. However, for other languages that require the full range of the UTF-8 character set, this has to be explicitly specified at a number of places, some SiteMesh specific, some app server specific/jsp specific.

Note that the examples below all refer to UTF-8. The same approach applies to any encoding other than iso-8859-1, and is not limited to UTF-8.

1. If possible, the web application should be configured to use UTF-8 as the default encoding. Orion allows this to be specific in orion-web.xml, as the default-charset attribute. Weblogic requires a context parameter named weblogic.httpd.inputCharset. See your application server documentation for more details. If the application server of choice does not allow to set the default charset for all web-apps, then every page (including the decorators) will need to specify the content-type. This is done by specifying a page header tag like this:

 
  1. <%@ page contentType="text/html; charset=utf-8"%>  

Note that some older versions of Orion do not respect the contentType page directive in included pages, so to be on the safe side, this directive should be specified in ALL pages, not just the top level one (one could use an include).

2. The next step is to inform the browser that the page contents are of a specific character set. This is done by specifying a meta tag in the HEAD element of the html page, like this:

 
  1. <META HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">  

3. The final step is informing SiteMesh's decorator mechanism that it should use a specific encoding other than the default. This is done by specifying an encoding attribute to the applyDecorator tag with the name of the encoding to use.

 
  1. <page:applyDecorator name="form" encoding="utf-8">  
  2.     ...  
  3. </page:applyDecorator>  

分享到:
评论

相关推荐

    SiteMesh教程及SiteMesh官方文档翻译

    ### SiteMesh教程及SiteMesh官方文档翻译 #### 使用SiteMesh简化网页布局 SiteMesh是一款用于Web应用程序中的页面布局和装饰的框架。它采用Decorator模式,通过过滤器(filter)拦截请求和响应,将不同的页面组件...

    sitemesh所需jar包ver2.4.1and 2.4.2

    SiteMesh是一款广泛应用于Java Web开发中的页面布局框架,它的主要功能是帮助开发者统一网站的页面样式和布局,提高页面设计的效率和一致性。在Java Web应用程序中,SiteMesh通过拦截HTTP请求,将用户请求的内容与...

    siteMesh demo+文档

    SiteMesh 是一个开源的Web应用程序布局和装饰框架,主要用于解决Web应用中的页面布局问题。它通过拦截HTTP请求,将页面内容与预定义的布局模板相结合,实现统一的页面头部、底部和侧边栏等元素,从而提高网站的整体...

    sitemesh框架简单例子

    Sitemesh是一款强大的Web页面布局和装饰框架,它主要用于帮助开发者实现网站的统一外观和感觉。这个框架的主要功能是将页面的主体内容与页眉、页脚、侧边栏等通用部分分离,使得在大量网页中保持一致的设计风格变得...

    sitemesh

    **Sitemesh** 是一个广泛使用的开源Web应用框架,它主要功能是提供页面布局和装饰功能,用于统一网站的外观和感觉。Sitemesh通过在Web应用中引入“母版”(Master Page)的概念,使得开发者可以轻松地创建一致性的...

    java sitemesh 页面框架

    Java Sitemesh是一个开源的页面布局和装饰框架,它的主要目标是帮助开发者统一网站的外观和感觉,提高代码复用性,并简化页面的复杂性。Sitemesh通过将页面分为内容区域和装饰模板来实现这一目标,使得开发者可以...

    SiteMesh

    SiteMesh 是一个开源的Web应用程序框架,主要用于帮助开发者实现页面布局和装饰功能。它通过拦截HTTP请求,将页面内容与布局模板相结合,从而提供了一种简单有效的方式来管理和控制Web应用的外观和感觉。在Web开发中...

    页面装饰器(sitemesh)实例源代码

    页面装饰器(Sitemesh)是一种广泛用于Web应用的开源框架,它的主要功能是提供页面布局和装饰功能,使得开发者可以方便地实现统一的页面头部、尾部、侧边栏等元素,从而提高网站的整体风格一致性。在本实例中,我们...

    sitemesh-2.2.1.jar sitemesh-2.2.1.jar

    **sitemesh-2.2.1.jar** 是一个用于Web应用程序界面布局的开源框架,由OpenSymphony团队开发。Sitemesh的主要功能是提供页面装饰能力,它可以帮助开发者统一网站的外观和感觉,实现页面模板和内容的分离。通过在...

    sitemesh3官方下载包

    **Sitemesh3** 是一个开源的网页布局和装饰框架,用于Java Web应用程序。它主要目的是帮助开发者统一网站的外观和感觉,通过提供一种简单的方式来装饰(或模板化)整个Web应用中的页面。Sitemesh3是Sitemesh项目的第...

    sitemesh3-demo

    【sitemesh3-demo】是一个基于Sitemesh3框架的示例项目,旨在展示如何在Web应用程序中有效地实现页面布局和装饰功能。Sitemesh是一个开源的Java Web应用框架,主要用于增强网页的外观和结构,通过定义装饰模板,可以...

    springMVC与sitemesh的结合

    而Sitemesh则是一个页面布局和装饰框架,主要用于处理Web应用中的页面布局问题,比如统一头部、底部和侧边栏,提升用户体验并简化开发。 将Spring MVC与Sitemesh结合使用,可以实现更高效的Web应用开发。以下是对这...

    sitemesh jar包机tld文件

    在Java Web开发中,SiteMesh是一个非常流行的页面布局框架,它可以帮助开发者轻松地实现网站的统一外观和感觉,以及提供页面装饰功能。标题中的“sitemesh jar包”指的是SiteMesh框架的核心库文件,它是SiteMesh功能...

    sitemesh.jar包

    sitemesh.jar包 sitemesh.jar 包sitemesh.jar 包sitemesh.jar包

    SiteMesh教程.pdf

    SiteMesh是一种用于Java Web应用的装饰器设计模式框架,主要通过拦截Web页面请求,动态地将装饰页面如头部(header)、底部(footer)、样式表(stylesheet)和脚本文件(scripts)等页面元素与实际页面组合在一起,...

    Sitemesh 3 的使用及配置

    ### Sitemesh 3 的使用及配置 #### 一、Sitemesh 3 简介 Sitemesh 是一个非常实用的Web页面布局与修饰框架,它通过Servlet中的Filter来实现网页的装饰功能,类似于ASP.NET中的“母版页”技术。这种技术允许开发者...

    sitemesh入门demo

    Sitemesh 是一个开源的网页布局和装饰框架,它主要负责处理Web应用程序的页面布局,使得开发者可以集中精力于应用的核心功能,而不用过多关注页面样式的一致性和美观性。Sitemesh 提供了一种优雅的方式来组织和装饰...

    sitemesh装饰器入门

    **Sitemesh装饰器入门** Sitemesh 是一个开源的 Web 应用程序框架,它主要用来帮助开发者实现页面布局和装饰功能。Sitemesh 的核心概念是“装饰器”,这个概念源自于软件设计模式中的装饰者模式。通过使用 Sitemesh...

    sitemesh例子

    **Sitemesh简介** Sitemesh 是一个开源的 Web 应用程序装饰框架,主要用于解决网页布局和页面统一风格的问题。它通过拦截 HTTP 请求,将请求的页面内容与预先定义好的模板结合,使得开发者可以轻松地创建出统一的...

Global site tag (gtag.js) - Google Analytics