JSP2.0较JSP1.0新增功能如下:
(1)Expression Language;
(2)新增Simple Tag和Tag File;
(3)web.xml新增<jsp-config>元素
Expression Language
JSP传统方法:
<%
String str_count=request.getParameter("count");
int count=Integer.parseInt(str_count);
count=count+5;
out.println(count);
%>
EL语法:
count:${param.count+5}
新增Simple Tag 和Tag File
Hello.tag
<%
out.println("Hello from tag file");
%>
将它放在WEB-INF/tags/目录下,在JSP页面使用Hello.tag方法如下:
<%taglib prefix="myTag" tagdir="/WEB-INF/tags"%>
<myTag:Hello>
web.xml新增<jsp-config>元素
<jsp-config>元素主要用来设定JSP相关配置,<jsp-config>包括<tablib>和<jsp-property-group>两个子元素。其中<taglib>元素在JSP1.2时候已经存在;而<jsp-property-group>是JSP2.0新增的元素。
本文介绍JSP2.0相较于JSP1.0的主要更新:引入表达式语言(EL)简化数据操作,新增SimpleTag和TagFile提高组件复用性,以及在web.xml中增加<jsp-config>元素进行更灵活的配置。
191

被折叠的 条评论
为什么被折叠?



