JSP EL的语法与基本使用
?
类型 |
示例 |
对应的调用方法 |
JavaBeans |
${user.username} ${user[“username”]} ${user[‘username’]} |
user.getUsername() |
数组 |
${hoby[1]} ${hoby[“1”]} ${hoby[‘1’]} |
hoby[1] |
List |
${adress[2]} ${adress[“2”]} ${adress[‘2’]} |
address.get(2) |
Map |
${phone[“home”]} ${phone[‘home’]} ${phone.home} |
Phone.get(“home”) |
JSP EL的内置对象
- pageContext
- pageScope
- requestScope
- sessionScope
- applicationScope
- param
- paramValues
- header
- headerValues
- cookie
- initParam
?? 例子:
?
<%session.getAttribute("phone")%> 等价于 ${sessionScope.phone}?
设定 JSP 不使用 JSP EL
- ?????? 使用 page 指令的 isELIgnored 属性
? <%@ page isELIgnored =”true”%>
- ????? 或者修改 web.xml
<web-app…> <jsp-config> <jsp-property-group> <url-pattern>*.jsp</url-pattern> <el-ignored>true</el-ignored? <jsp-property-group> </jsp-config> </web-app>?
?