Struts 2 <s:textarea> example
Previous | Home | Next |
The Struts 2.0 framework provide textarea input element through the<s:textarea></s:textarea> tag.This tag provide the facility to get textarea input .The Struts 2 textarea component provide the following <s:textarea></s:textarea> tag:<textarea name="address" cols="40" rows="10" id="s" label="Address"></textarea>
Directory Structure of <s:textarea> tag Example in Struts 2.0 Using MyEclipse IDEindex.jsp<%@taglib uri="/struts-tags" prefix="s"%> <h3>Struts 2 Framework TextArea Tag example</h3> <s:form action="txtarea"> <s:textarea name="address" label="Address" cols="20" rows="10"></s:textarea> <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="txtarea" class="org.r4r.TextAreaAction"> <result name="success">/success.jsp</result> </action> </package> </struts>TextAreaAction.javapackage org.r4r; public class TextAreaAction { private String address; public String execute(){ return "success"; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } }success.jsp<%@taglib uri="/struts-tags" prefix="s" %> <h3>Struts 2 Framework TextArea Tag example</h3> <br/> My Address :-<s:property value="address"/>Output
Previous | Home | Next |