Struts2.2.1 label Tag Example
Posted on: January 19, 2011 at 12:00 AM
The label tag is used to renders an HTML LABEL that allow to output.

Struts2.2.1 label Tag Example

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"ADS_TO_REPLACE_1

pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">ADS_TO_REPLACE_2

<%@taglib prefix="s" uri="/struts-tags"%>

<html>

<head>ADS_TO_REPLACE_3

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Example Label Tag</title>

</head>ADS_TO_REPLACE_4

<body>

label1:<s:label value="Roseindia" /><br>

label2:<s:label value="Technology" />ADS_TO_REPLACE_5

<br>

<s:textfield label="Roseindia"/><br>

<s:textfield label="Technology"/>ADS_TO_REPLACE_6

</body>

</html>

Here is the Struts.xml file.

<?xml version="1.0" encoding="UTF-8"?>ADS_TO_REPLACE_7

<!DOCTYPE struts PUBLIC

"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"

"http://struts.apache.org/dtds/struts-2.0.dtd">ADS_TO_REPLACE_8

<struts>

<constant name="struts.enable.DynamicMethodInvocation" value="false" />

<constant name="struts.devMode" value="true" />ADS_TO_REPLACE_9

<constant name="struts.custom.i18n.resources" value="ApplicationResources" />

<package name="default" namespace="/" extends="struts-default">

<action name="Label" class="roseindia.LabelTag">ADS_TO_REPLACE_10

<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-ADS_TO_REPLACE_11

Output:-

 

Download Select Source CodeADS_TO_REPLACE_12

Related Tags for Struts2.2.1 label Tag Example:

Advertisements

Ads

Ads

 
Advertisement null

Ads