The label tag is used to renders an HTML LABEL that allow to output <s: label name=? ? value=? ? /> combination that has the same format treatment as the rest of UI controls.The following Example will shows how to implement the label tag in the Struts2.2.1 --
First we create a JSP file named Label.jsp as follows.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><! DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd" ><%@ taglib prefix="s" uri="/struts-tags"%>< html>< head>< meta http-equiv="Content-Type" content="text/html; charset=UTF-8">< title>Example Label Tag</title></ head>< body>label1: <s:label value="Roseindia" /><br>label2: <s:label value="Technology" /> <br> <s:textfield label="Roseindia"/><br> <s:textfield label="Technology"/></body> </html> |
Here is the Struts.xml file.
<? 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><constant name="struts.enable.DynamicMethodInvocation" value="false" /> <constant name="struts.devMode" value="true" /> <constant name="struts.custom.i18n.resources" value="ApplicationResources" /><package name="default" namespace="/" extends="struts-default"> <action name="Label" class="roseindia.LabelTag"> <result name="success">/index.jsp</result></action> </package></struts> |
This Program produces output on the basis of the label Tag evaluation, This give the output as-
Output:-
Advertisements
Ads
Ads