jsp遍历所有数据标签与转义标签(3)
来源:未知 责任编辑:责任编辑 发表时间:2015-09-17 09:43 点击:次
request.setAttribute("map",map);
%>
<example:forEachAll items="${map}" var="map">
${ map.key}-------${ map.value }<br>
</example:forEachAll>
<hr>
<%
String[] strs = {"asd","fff","v","tt"};
request.setAttribute("strs",strs);
%>
<example:forEachAll items="${strs}" var="str">${str}<br></example:forEachAll>
<hr>
<%
int[] i = {1,2,3,4};
request.setAttribute("i",i);
%>
<example:forEachAll items="${i}" var="num">${num}<br>
</example:forEachAll>
</body>
</html>
注:描述文件与前面博客的forEach标签的定义一样,这里就不啰嗦的列出,不懂的可以去看上一篇博客
2. 开发html转义标签案例分析:
标签处理类:
package com.csdn.web.example;
import java.io.IOException;
import java.io.StringWriter;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.JspFragment;
import javax.servlet.jsp.tagext.SimpleTagSupport;
publicclass HtmlFilter extends SimpleTagSupport {
@Override
publicvoid doTag() throws JspException, IOException {
JspFragment jf = this.getJspBody();
StringWriter sw = new StringWriter();
jf.invoke(sw);
String s = sw.toString();
相关新闻>>
- 发表评论
-
- 最新评论 更多>>