blob: 088ed2065f042c0b9d8f62da81297f2fa9c1f1b0 [file] [log] [blame]
Hongqing Liufd5ee812014-05-10 16:32:51 +08001<html><body><pre>
刘洪青6266f992017-05-15 21:21:03 +08002&lt;%--
Hongqing Liufd5ee812014-05-10 16:32:51 +08003 Licensed to the Apache Software Foundation (ASF) under one or more
4 contributor license agreements. See the NOTICE file distributed with
5 this work for additional information regarding copyright ownership.
6 The ASF licenses this file to You under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with
8 the License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
刘洪青6266f992017-05-15 21:21:03 +080017--%>
Hongqing Liufd5ee812014-05-10 16:32:51 +080018&lt;%@ taglib prefix="my" uri="http://tomcat.apache.org/jsp2-example-taglib"%>
19
20&lt;html>
21 &lt;head>
22 &lt;title>JSP 2.0 Examples - jsp:attribute and jsp:body&lt;/title>
23 &lt;/head>
24 &lt;body>
25 &lt;h1>JSP 2.0 Examples - jsp:attribute and jsp:body&lt;/h1>
26 &lt;hr>
刘洪青6266f992017-05-15 21:21:03 +080027 &lt;p>The new &amp;lt;jsp:attribute&amp;gt; and &amp;lt;jsp:body&amp;gt;
Hongqing Liufd5ee812014-05-10 16:32:51 +080028 standard actions can be used to specify the value of any standard
29 action or custom action attribute.&lt;/p>
30 &lt;p>This example uses the &amp;lt;jsp:attribute&amp;gt;
31 standard action to use the output of a custom action invocation
32 (one that simply outputs "Hello, World!") to set the value of a
33 bean property. This would normally require an intermediary
34 step, such as using JSTL's &amp;lt;c:set&amp;gt; action.&lt;/p>
35 &lt;br>
36 &lt;jsp:useBean id="foo" class="jsp2.examples.FooBean">
37 Bean created! Setting foo.bar...&lt;br>
38 &lt;jsp:setProperty name="foo" property="bar">
39 &lt;jsp:attribute name="value">
刘洪青6266f992017-05-15 21:21:03 +080040 &lt;my:helloWorld/>
Hongqing Liufd5ee812014-05-10 16:32:51 +080041 &lt;/jsp:attribute>
42 &lt;/jsp:setProperty>
43 &lt;/jsp:useBean>
44 &lt;br>
45 Result: ${foo.bar}
46 &lt;/body>
47&lt;/html>
48</pre></body></html>