小弟纯新手。。遇到这个问题只有傻愣着。。 <tag>
<description>Hello TEI</description>
<name>Hello_TEI</name>
<tag-class>ch15.Hello_TEI</tag-class>
<body-content>empty</body-content>
<variable>
<name-from-attribute>id</name-from-attribute>
<variable-class>String</variable-class>
<declare>true</declare>
<scope>AT_END</scope>
</variable>
</tag>也就是这个<name-from-attribute>id</name-from-attribute> 之间这个id的问题
书上是说<%@ page contentType="text/html;charset=Big5" %>
<%@ taglib uri="MyTaglib" prefix="mytag" %><html>
<head>
<title>CH15 - Hello_TEI.jsp</title>
</head>
<body> <h1><mytag:Hello_TEI id="Message"/></h1>
${ Message } </body>
</html>中,可用 id="Message" 来动态设定可用在tag与jsp页面间交互的变量的名字,也就是"${ Message }",但是这样一来如何设置这一变量的值呢。。
若是没有使用这个<name-from-attribute>id</name-from-attribute> 而是直接使用<name-given>Message</name-given>,则可以直接在taglib handler class中使用 pageContext.setAttribute()来设置这个变量的值。
<description>Hello TEI</description>
<name>Hello_TEI</name>
<tag-class>ch15.Hello_TEI</tag-class>
<body-content>empty</body-content>
<variable>
<name-from-attribute>id</name-from-attribute>
<variable-class>String</variable-class>
<declare>true</declare>
<scope>AT_END</scope>
</variable>
</tag>也就是这个<name-from-attribute>id</name-from-attribute> 之间这个id的问题
书上是说<%@ page contentType="text/html;charset=Big5" %>
<%@ taglib uri="MyTaglib" prefix="mytag" %><html>
<head>
<title>CH15 - Hello_TEI.jsp</title>
</head>
<body> <h1><mytag:Hello_TEI id="Message"/></h1>
${ Message } </body>
</html>中,可用 id="Message" 来动态设定可用在tag与jsp页面间交互的变量的名字,也就是"${ Message }",但是这样一来如何设置这一变量的值呢。。
若是没有使用这个<name-from-attribute>id</name-from-attribute> 而是直接使用<name-given>Message</name-given>,则可以直接在taglib handler class中使用 pageContext.setAttribute()来设置这个变量的值。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货