Newsletter |
Struts 2 Tabbedpanel Example
Struts » on Oct 27, 2011 { 11 Comments } By Sivateja
Let us see how to work with this struts 2 Tabbedpanel.
jars required
- commons-logging-1.0.4.jar
- freemarker-2.3.8.jar
- ognl-2.6.11.jar
- struts2-core-2.0.11.jar
- xwork-2.0.4.jar
Example
files required
- index.jsp
- success.jsp
- web.xml
- struts.xml
- LogingEx.java
Directory Structure
index.jsp
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=resultAction.action">
success.jsp
<%@ taglib prefix="s" uri="/struts-tags" %> <head> <s:head theme="ajax" debug="true"/> </head> <body> <s:tabbedPanel id="test" > <s:div id="one" label="Tab 1" theme="ajax"> java4s.com --> First Tab<br><br> </s:div> <s:div id="two" label="Tab 2" theme="ajax"> php4s.com --> second Tab<br><br> </s:div> <s:div id="three" label="Tab 3" theme="ajax"> java4s.com --> 3rd Tab<br><br> </s:div> <s:div id="four" label="Tab 4" theme="ajax"> java4s.com --> 4th Tab<br><br> </s:div> </s:tabbedPanel> </body>
LogingEx.java
package java4s; import com.opensymphony.xwork2.ActionSupport; public class LogingEx extends ActionSupport{ private static final long serialVersionUID = 1L; public String execute(){ return SUCCESS; } }
web.xml
<?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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <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>
struts.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <include file="struts-default.xml"/> <package name="a" extends="struts-default"> <action name="resultAction" class="java4s.LogingEx"> <result name="success">/success.jsp</result> <result name="error">/error.jsp</result> </action> </package> </struts>
Output
You Might Also Like
::. About the Author .:: | ||
Comments
11 Responses to “Struts 2 Tabbedpanel Example”
Am getting error in this program as No tag “tabbedPanel” defined in tag library imported with prefix “s”.
I downloaded the source code. The code of success.jsp is of another concept but not of tabbedpanel.
Please help.
@Vaseem
Gosh, some thing went wrong.
I have updated the files, please download & check it again.
Thank a lot vaseem.
Hello java4s,
The rar file is showing me garbage data. how can i open this file?
@Saloni
Download that .rar file and open with WinRar software. I have tested and working fine from my end.
i have downloaded .rar file and copied content in my project but still it is not showing proper output as u shown above. i new to struts.
@durgesh kumawat
What type of error you are getting…?
It is not enough to paste the jar files in lib folder.You need to add all 5 jar files to your project build path (right click on project stuts-tabbed-paneEx -select bulid path-select configure build path-click add jars-select all jar iles under you project’s lib-click ok)
thanks good job easy to learn to freasher
Very useful for the beginners.Thank you so much..
Retrieving menu and submenu from database.
how can use hashmap here? and create menu and submenu.
Very good working example i like it its running successfully