0
HelloTag.Javaswitch语句/迭代中JSTL
public class HelloTag extends SimpleTagSupport {
@Override
public void doTag() throws JspException, IOException {
JspWriter out = getJspContext().getOut();
ArrayList outerList = new ArrayList();
ArrayList innerList = null;
for (int i = 0; i < 5; i++) {
innerList = new ArrayList();
innerList.add("1");
innerList.add("Name");
outerList.add(innerList);
}
for (int i = 0; i < outerList.size(); i++) {
for (int j = 0; j < innerList.size(); j++) {
out.println(innerList.get(j));
}
}
}
}
在JSP文件, 还有就是下面的代码片段:
<body>
<ct:Hello></ct:Hello>
</body>
当我运行JSP文件,该文件显示准确的结果;但
我要采取一切价值都是来自于自定义标签类的决定
如
<c:set var="name" scope="" value=""/>
<c:choose>
<c:when test="${name == 1}">
This is Your ID:-
</c:when>
<c:otherwise>
This is Your Name
</c:otherwise>
</c:choose>
上面的代码是只是举例的缘故。请更新我如何对来自自定义标记类的每个值做出决定。
解释我的问题另一种方法是,我要存储在一个变量的每一个值,然后取一个大约只使用JSTL不Scriplet标签着眼于上述方案(HelloTag.Java)
该值决定
据我所知,SimpleTagSupport不允许你有JSP主体内容,如果要实现类似,那么你需要使用BodyTagSupport –
Dapeng
2012-03-02 09:26:49
亲爱@Dapeng东西,我将通过一个例子来解决问题 – 2012-03-02 14:40:22