当前位置: 代码迷 >> Web前端 >> EL表达式中对pageContext暗含对象的调用
  详细解决方案

EL表达式中对pageContext暗含对象的调用

热度:220   发布时间:2012-11-26 11:48:49.0
EL表达式中对pageContext隐含对象的调用

  1. <%@?page?language="java"?import="java.util.*"?pageEncoding="utf-8"%>??
  2. <%??
  3. String?path?=?request.getContextPath();??
  4. String?basePath?=?request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";??
  5. %> ?
  6. <!DOCTYPE?HTML?PUBLIC?"-//W3C//DTD?HTML?4.01?Transitional//EN">??
  7. <html>??
  8. ??<head>??
  9. ????<base?href="<%=basePath%>"> ?
  10. ????<title>My?JSP?'PageContext.jsp'?starting?page</title> ?
  11. ????<meta?http-equiv="pragma"?content="no-cache">??
  12. ????<meta?http-equiv="cache-control"?content="no-cache">??
  13. ????<meta?http-equiv="expires"?content="0">??????
  14. ????<meta?http-equiv="keywords"?content="keyword1,keyword2,keyword3">??
  15. ????<meta?http-equiv="description"?content="This?is?my?page">??
  16. ????<!--??
  17. ????<link?rel="stylesheet"?type="text/css"?href="styles.css">??
  18. ????--> ?
  19. ??</head>??
  20. ????
  21. ??<body>??
  22. ???????<table?border="1"?align="center"?>??
  23. ???????????<tr>??
  24. ? ? ? ? ? ? ?<td>PageContext隐含对象的调用</td>??
  25. ???????????????<td>说明</td>??
  26. ???????????????<td>调用结果</td>??
  27. ???????????</tr>??
  28. ???????????<tr>??
  29. ???????????????<td>\${pageContext.request.queryString?}</td>??
  30. ???????????????<td>获取参数</td>??
  31. ???????????????<td>${pageContext.request.queryString?}</td>??
  32. ???????????</tr>??
  33. ???????????<tr>??
  34. ???????????????<td>\${pageContext.request.requestURL?}</td>??
  35. ???????????????<td>获取当前页面的地址,但是包含请求的参数</td>??
  36. ???????????????<td>${pageContext.request.requestURL?}</td>??
  37. ???????????</tr>??
  38. ???????????<tr>??
  39. ???????????????<td>\${pageContext.request.contextPath?}</td>??
  40. ???????????????<td>web的应用名称</td>??
  41. ???????????????<td>${pageContext.request.contextPath?}</td>??
  42. ???????????</tr>??
  43. ???????????<tr>??
  44. ???????????????<td>\${pageContext.request.method?}</td>??
  45. ???????????????<td>获取http的方法(get或post)</td>??
  46. ???????????????<td>${pageContext.request.method?}</td>??
  47. ???????????</tr>??
  48. ???????????<tr>??
  49. ???????????????<td>\${pageContext.request.remoteAddr?}</td>??
  50. ???????????????<td>获取用户的IP地址</td>??
  51. ???????????????<td>${pageContext.request.remoteAddr?}</td>??
  52. ???????????</tr>??
  53. ???????????<tr>??
  54. ???????????????<td>\${pageContext.session.id?}</td>??
  55. ???????????????<td>获取session的id属性值</td>??
  56. ???????????????<td>${pageContext.session.id?}</td>??
  57. ???????????</tr>??
  58. ?????????????
  59. ???????</table>??
  60. ??</body>??
  61. </html> ?
  62. 原文地址: http://www.heatpress123.net/cpzs/