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.