|
Struts2 Data Tags |
|
struts.xml
<action name=”textTag”
class=”net.javajazzup.textTag”>
<result>/pages/dataTags/textTag.jsp</
result>
</action>
Create an action class as shown below:
textTag.java
package net.javajazzup;
import
com.opensymphony.xwork2.ActionSupport;
public class textTag extends ActionSupport {
public String execute() throws Exception{
return SUCCESS;
}
}
Create a property file in the same package
where your Java program file (textTag.java) is
saved with the name as
package.properties.
package.properties
webname1 = http://www.javajazzup.com
webname2 = http://www.roseindia.net
webname3 = http://www.newstrackindia.com
Now create a jsp page to see the working of
the text tags.
The first three tags <s:text
name=”webname1">,<s:text
name=”webname2"> and <s:text
name=”webname3"> uses the
package.properties file to display the text
message.
|
|
The next tag
<s:text name=”empname”>Vinod, Amit,
Sushil, .......</s:text> uses the body of the
tag as a default message.
The last tag <s:text name=”empname”>
</s:text> does not have access to the
package.properties files nor does it have a
body so it uses name of the message to
display.
textTag.jsp
<%@ taglib prefix=”s” uri=”/struts-tags” %>
<html>
<head>
<title>Text Tag Example</title>
</head>
<body>
<h2>Text Tag Example</h2>
<s:text name=”webname1"></s:text><br>
<s:text name=”webname2"></s:text><br>
<s:text name=”webname3"></s:text><br>
<s:text name=”empname”>Emp1,Emp2....
</s:text><br>
<s:text name=”empname”></s:text>
</body>
</html>
Output of the textTag.jsp:
|
|
Jan 2008 | Java Jazz Up | 49 |
|
|
|
View All Topics |
All Pages of this Issue |
Pages:
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53 ,
54,
55,
56,
57,
58,
59,
60,
61,
62,
63 ,
64,
65 ,
66 ,
67 ,
68 ,
69 ,
70 ,
71 ,
72 ,
73 ,
74 ,
75 ,
76 ,
77 ,
78 ,
79 ,
80 ,
81 ,
82 ,
83,
84 ,
85 ,
86,
87 ,
88,
89 ,
90 ,
91 ,
92 ,
93 ,
94 ,
95 ,
96 ,
97 ,
98 ,
99 ,
100 ,
101 ,
102 ,
103,
104 ,
105 ,
106,
107,
Download PDF |
|
|
|
|
|
|
|
|
|