Include tag example in struts2 framework
Previous | Home | Next |
The Struts2 framework provide "include" tag, this tag provide to include JSP and HTML page in current web page.Syntax of include tag:-<s:include value=""></s:include>
The struts2 framework provide following include tag example,<s:include value="hello.jsp"></s:include>
Directory Structure of <s:include> tag Example in Struts 2.0 Using MyEclipse IDEindex.jsp<%@ taglib prefix="s" uri="/struts-tags" %> <h1>Include tag example in struts2 framework</h1> <s:include value="hello.jsp"></s:include>web.xml<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <filter> <filter-name>f1</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> <filter-name>f1</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>struts.xml<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"> <struts> <package name="demo" extends="struts-default"> <action name="" class="org.r4r.IncludeTagAction"> <result name="success" type="dispatcher">/index.jsp</result> </action> </package> </struts>IncludeTagAction.javapackage org.r4r; public class IncludeTagAction { public String execute(){ return "success"; } }hello.jsp<h4>This result is generated by include Tag in struts2 framework</h4>Output
Previous | Home | Next |