Struts2.2.1 sitemesh and freemarker configuration

2011-01-02  来源:本站原创  分类:Java  人气:73 

Import the package:
struts2-core-2.2.1.jar
struts2-sitemesh-plugin-2.2.1.jar
sitemesh-2.4.2.jar

web.xml configuration

Filter configuration :
    <filter>
        <filter-name>struts-prepare</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter</filter-class>
    </filter> 

        <filter>
        <filter-name>sitemesh</filter-name>
        <filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class>
    </filter>

        <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
        </filter>

        <filter-mapping>
        <filter-name>struts-prepare</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

        <filter-mapping>
                <filter-name>sitemesh</filter-name>
                <url-pattern>/*</url-pattern>
        </filter-mapping>

        <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
        </filter-mapping>

 Listener configuration :
    <servlet>
        <servlet-name>sitemesh-freemarker</servlet-name>
        <servlet-class>org.apache.struts2.sitemesh.FreemarkerDecoratorServlet</servlet-class>
        <init-param>
            <param-name>default_encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>sitemesh-freemarker</servlet-name>
        <url-pattern>*.ftl</url-pattern>
    </servlet-mapping>
        <listener>
        <listener-class>org.apache.struts2.dispatcher.ng.listener.StrutsListener</listener-class>
    </listener>

sitemesh.xml

<sitemesh>
    <property name="decorators-file" value="/WEB-INF/decorators.xml"/>
    <excludes file="${decorators-file}"/>

    <page-parsers>
        <parser default="true"/>
        <parser content-type="text/html"/>
    </page-parsers>

    <decorator-mappers>
        <mapper>
            <param name="config" value="${decorators-file}"/>
        </mapper>
    </decorator-mappers>
</sitemesh>

decorators.xml

<decorators defaultdir="/decorators">
    <excludes>
        <pattern>/index.html</pattern>
    </excludes>

    <decorator name="default" page="default.ftl">
        <pattern>/*</pattern>
    </decorator>
</decorators>
相关文章
  • Struts2.2.1 sitemesh and freemarker configuration 2011-01-02

    Import the package: struts2-core-2.2.1.jar struts2-sitemesh-plugin-2.2.1.jar sitemesh-2.4.2.jar web.xml configuration Filter configuration : <filter> <filter-name>struts-prepare</filter-name> <filter-class>org.apache.struts2.dispat

  • Struts2 in several properties and xml configuration files 2010-03-29

    Struts2 in several properties and xml configuration files in the form of placement, role, fear forget, be a notebook first 1, struts.properties placed in the src directory 2, application-level resource file internationalization messageResource_en_US.

  • Struts2 in the internationalization of the FreeMarker configuration 2010-03-29

    The Struts2 using FreeMarker as the presentation layer is basically configured as a universal. However, developers are familiar with JSP accustomed to the use of JSP tags, while the use of FreeMarker macros indeed, although some differences between t

  • spring + struts2 + hibernate + freemarker configuration problem again Summary 2010-11-20

    web container: tomcat5/tomcat6 jdk version: jdk1.6 spring version: 3.05 struts version: 2.1.6 hibernate version: 3.6 freemarker version: 2.3.16 All the jar packages are as follows: Configuration process took longer, often encountered lack of class an

  • struts2 + hibernate3.2 + spring2.0 instance configuration + Getting Started 2010-04-13

    eclipse3.2, myeclipse5.0, Jboss4.0.3, sql server2000 sp3 Principle of In the java enterprise applications, ejb powerful ejb configuration with the complex and difficult to learn as well known. But in the past and what we do? Just bite the bullet and

  • Struts2.1.8 Unable to load configuration exception 2010-08-17

    Xin Sun wrote today to see "Struts2 depth In Visual FoxPro ", the follow the steps to deploy a web project, which is the classical language Less HelloWorld, as required jar files into the corresponding commons-logging-1.0.4.jar, freemarker-2.3.1

  • struts2.18 + spring2.5 + hibernate3.2 configuration, boot-time fault 2009-07-15

    Error prompt Serious : Exception starting filter struts2 Class: org.apache.struts2.osgi.OsgiConfigurationProvider File: OsgiConfigurationProvider.java Method: init Line: 70 - org/apache/struts2/osgi/OsgiConfigurationProvider.java:70:-1 at org.apache.

  • struts2 small example of the simplest configuration 2008-05-25

    Here is the struts2 and spring Examples of combination . struts2 Framing is simple , 1. Landing http://struts.apache.org, Download the struts2 package , First download the struts2 package to your webproject The/WEB-INF/lib file. . 2. After you modify

  • Struts2 in a paging macro Freemarker integration 2010-07-30

    Essays of a record. There are two reference classes, import java.util.List; /** * Pagination display objects * @param <T> */ public class PageView<T> { /** Paging data **/ private List<T> records; /** The page number starting index and t

  • Struts2 configuration and sitemesh 2009-10-29

    Integration of the Spring / Webwork / Sitemesh / FreeMarker configuration related web.xml need to configure the three filter, which filter the order of 3 can not be reversed, must be in accordance with the following order: one ActionContextCleanUp se

  • FreeMarker in struts2.0, JAVA, web application examples [change] 2009-11-08

    FreeMarker Overview FreeMarker is a template engine generates text output based on the template a common tool for the preparation of the use of pure Java Template + data model = output FreeMarker is a very good template engine, the template engine ca

  • FreeMarker in struts2.1.8, JAVA, web application example 2010-04-11

    FreeMarker Overview FreeMarker is a template engine, a template generates text output based on a common tool, written using pure Java Template + data model = output FreeMarker is a very good template engine, template engine that can be used for any s

  • struts2 simple configuration 2010-04-14

    Struts2 is the Apache open source under a layer of very practical in view of the framework. (1) apache website to download item to download struts. (2) using myeclipse to create a web project, called first_struts, then the corresponding struts2 freem

  • FreeMarker in struts2, JAVA, web application example 2011-09-15

    Overview of FreeMarker * FreeMarker is a template engine, a template-based generic tool to generate text output, use the pure Java * Template + data model = output FreeMarker is a very good template engine, template engine that can be used in any sce

  • struts2.1.6 struts2.1.6 version with previous versions of configuration differences 2011-07-13

    struts2.1 Struts2.0 upgrade , So their configuration is a little different places . struts2.1.6 Versions prior to configuration : <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-

  • 通过引入SiteMesh的JSP标签库,解决Freemarker与SiteMesh整合时,自定义SiteMesh标签的问题 2015-05-03

    不少web项目,都用到了SiteMesh.SiteMesh可以和JSP.Freemarker等模版进行整合,有一定的好处,当然也有其不好的地方.我个人觉得,如果没有必要,不要在项目中引入太多的工具和技术,工具多了,项目开发的速度提高不起来. 以前,主要是用JSP作为视图层,最近主要是用Freemarker,然后配置Freemarker和SiteMesh整合. 项目中,最初的做法如下所示. <html> <head> ${head} </head> <body>

  • struts2.0 of Action of the object life-cycle Xiangjie!! 2010-04-04

    struts2.0 of Action of the object life-cycle Xiangjie! ! Many people have asked Struts2.0 objects are thread-safe since, and not a single cases of mode, when it actually creates, when it destroyed? Struts2.0 in this and the configuration of the relev

  • Process to build the first one struts2 2010-04-06

    1. Myeclipse to build a Web Project, in the latest struts2 2.1.8.1 need to join the struts2 package has 6 (struts2-core, freemarker, ognl, xwork, common-logging, common-fileupload), if the previous version of the then do not join the common-fileuploa

  • struts2 + spring2.5 + hibernate3.2 + MySQL5 fully integrated 2010-04-13

    struts2 + spring2.5 + hibernate3.2 + MySQL5.1 Learning is still school tutorials, according to their own understanding, through a simple user login detection framework for the implementation to complete the three kinds of structures, all documents an

  • Struts2 constant Glance 2008-07-31

    Struts2 constant at a glance: struts.configuration This attribute specifies the Struts 2 configuration file loads the configuration file manager. The default value of the property org.apache.Struts2.config.DefaultConfiguration, which is Struts 2 defa