日期:2014-05-16 浏览次数:20371 次
大家总是不喜欢看到<%和%>在jsp页面上,其实我们可以使用比较优雅的xml方式来表达
1
,隐含的注释
JSP语法:<%--?内容?--%>
XML语法:无
2
,变量或函数的声明
JSP语法:<%!?declaration;
[
declaration;
]
+...?%>
例如:
<%!?
???
int?
i=
0
;
int?
a,b,c;
???
Color?red=
new?
Color
(
255
,
0
,
0
)
;
???
private?static?final?
String?OK=
"ok"
;
???
public?
String?getAnswer
(){
???????
return?
OK;
???
}
%>
XML语法:
<jsp:declaration>
????
declartion;
[
declaration;
]
+...
</jsp:declaration>
例如:
<jsp:declaration>
???
int?
i=
0
;
int?
a,b,c;
???
Color?red=
new?
Color
(
255
,
0
,
0
)
;
???
private?static?final?
String?OK=
"ok"
;
???