Struts2 combine Sitemesh3 to make a site master page

Source: Internet
Author: User

The previous article introduced the use of SITEMESH3, this article describes how to combine struts2 to configure and use Sitemesh, specific how to use SITEMESH3 I will not explain, this you can look at my previous blog.

First you will add struts and Sitemesh related jar packages:

Once added, you will configure the Web. xml file:

<?xml version= "1.0" encoding= "UTF-8"?>
<web-app xmlns:xsi= "http://www.w3.org/2001/ Xmlschema-instance "
    xmlns=" Http://java.sun.com/xml/ns/javaee "
    xsi: schemalocation= "Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
     id= "webapp_id" version= "3.0" >
    <!--used to eliminate the Sitemesh Interceptor Struts2 interceptor Conflict compatibility
    <filter>
        <filter-name> Struts-cleanup</filter-name>
        <filter-class> Org.apache.struts2.dispatcher.actioncontextcleanup</filter-class>
    </filter>

<filter>
<filter-name>sitemesh3</filter-name>
<filter-class>org.sitemesh.config.ConfigurableSiteMeshFilter</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-cleanup</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

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

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

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

</web-app>

Configure the Struts.xml file after you have configured it:

<?xml version= "1.0" encoding= "UTF-8"?>
<! DOCTYPE Struts Public
"-//apache software foundation//dtd Struts Configuration 2.3//en"
"Http://struts.apache.org/dtds/struts-2.3.dtd" >

<struts>

<constant name= "Struts.enable.DynamicMethodInvocation" value= "false"/>
<constant name= "Struts.devmode" value= "true"/>

<package name= "Aboutme" extends= "Struts-default" >
<action name= "Aboutme"
class= "Zw.hellozw.action.AboutMeAction" >
<result>/AboutMe.jsp</result>
</action>
<!--Add Actions--
</package>

</struts>

Then you visit to see:

What are the questions you can send to my email address:[email protected], or qq:1576410833.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.