Struts 2 <s:hidden> hidden value example
Previous | Home | Next |
The Struts 2.0 framework provide hidden input element through the<s:hidden></s:hidden> tag.This tag provide the facility to get hidden input .The Struts 2 hidden component provide the following <s:hidden></s:hidden> tag:<s:hidden label="URL" name="urlname" value="http://www.r4r.co.in"/>
Directory Structure of <s:hidden> tag Example in Struts 2.0 Using MyEclipse IDEindex.jsp<%@taglib uri="/struts-tags" prefix="s"%> <h3>Struts 2 Framework Hidden Tag example</h3> <h3>This page is hidden page</h3> <s:form action="url"> <s:hidden name="urlname" label="UrlName" value="http://www.r4r.co.in"></s:hidden> <s:submit value="Submit"></s:submit> </s:form>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="url" class="org.r4r.HiddenAction"> <result name="success">/success.jsp</result> </action> </package> </struts>HiddenAction.javapackage org.r4r; public class HiddenAction { private String urlname; public String execute(){ return "success"; } public String getUrlname() { return urlname; } public void setUrlname(String urlname) { this.urlname = urlname; } }success.jsp<%@taglib uri="/struts-tags" prefix="s" %> <h3>Struts 2 Framework Hidden Tag example</h3> <br/> URL-<s:property value="urlname"/>Output
Previous | Home | Next |