JSP
2019-07-09 本文已影响0人
总瓢把子
内置对象
`request` : HttpServletRequest 一次请求~请求
`response` : HttpServletResponse 一次请求~响应对象
`out` : JspWriter
`config` : ServletConfig
`page` : Object 当前Servlet页面对象 this
`exception` : Throwable 必须设置 `isErrorPage=ture`
`pageContext` : PageContext 当前页面共享数据,可以获取其他8个对象
`session` : HttpSession 一次会话de多个请求
`application` : ServletContext 所有用户
EL表达式
语法
${域名.键名}
pageScope相当于pageContext
requestScope相当于request
sessionScope相当于session
applicationScope相当于application(ServletContext)
-
${键名}如果没有写域名,默认从小到大查找改建对应的值
- 获取对象、List集合、Map集合中的值
- 对象 : ${域名.键名.属性名}
- List集合 : ${域名.键名[索引]}
- Map集合 :
{域名.键名["key"]}
隐式对象
-
el表达式中有11个隐式对象 -
pageContext:- 获取
jsp其他8个内置对象-
${pageContext.request.contextPath}: 动态获取虚拟目录
-
- 获取
JSTL
常用的JSTL标签
-
iftest属性 :接收boolean表达式,结果为true,显示,为false则不显示通常
test属性经常与el表达式结合使用 -
choose:相当于switch
choose==>switch
when==>case
otherwise==>default
-
foreach:for