53pagecontext对象

简介: 53pagecontext对象

image.png

建立一个test08
<%@ page language="java" contentType="text/html; charset=UTF-8"
     pageEncoding="UTF-8"%>
 <!DOCTYPE html>
 <html>
 <head>
 <meta charset="ISO-8859-1">
 <title>Insert title here</title>
 </head>
 <body>
 <h1>request对象</h1>
 <hr>
 <form action="response.jsp" name="regForm" method="post">
 <table>
 <tr>
 <td>用户名:</td>
 <td><input type="text" name="username"/></td>
 </tr>
 <tr>
 <td>爱好:</td>
 <input type="checkbox" name="favorite" value="read"/>读书
 <input type="checkbox" name="favorite" value="music"/>音乐
 <input type="checkbox" name="favorite" value="movie"/>电影
 <input type="checkbox" name="favorite" value="internet"/>上网
 </tr>
 <tr>
 <td colspan="2"><input type="submit" value="登录"></td>
 </tr>
 </table>
 </form>
 <br>
 <br>
 <a href="requset.jsp?username=lisi">url</a>
 </body>
 </html>建立一个test11
<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8"
     pageEncoding="UTF-8"%>
 <!DOCTYPE html>
 <html>
 <head>
 <meta charset="ISO-8859-1">
 <title>Insert title here</title>
 </head>
 <body>
 <h1>pagecontext</h1>
 <hr>
 用户名:<%=pageContext.getSession().getAttribute("username") %><br>
 <%
     //跳转到注册页面
     pageContext.forward("test08.jsp");
 %>
 </body>

image.png

相关文章
|
7月前
|
前端开发 Java Spring
方法参数相关属性params、@PathVariable和@RequestParam用法与区别
方法参数相关属性params、@PathVariable和@RequestParam用法与区别
47 0
|
10月前
|
缓存 安全 Java
JSP内置对象总结
JSP内置对象总结
94 0
|
Java
PageContext request session application区别以及EL表达式
PageContext request session application区别以及EL表达式
80 0
|
应用服务中间件
39jsp内置对象39jsp内置对象
39jsp内置对象39jsp内置对象
83 0
39jsp内置对象39jsp内置对象
JavaWeb - request 对象中 getContextPath() 方法介绍
JavaWeb - request 对象中 getContextPath() 方法介绍
157 0
JavaWeb - request 对象中 getContextPath() 方法介绍
|
Java Maven
JSP 使用 ${pageContext.request.contextPath} 无效
通过 ${pageContext.request.contextPath}可在JSP 中取得当前的项目绝对路径,比如当前项目是 http://localhost:8080/demo, 则 ${pageContext.request.contextPath} 代表的就是 /demo,其中 / 代表 http://localhost:8080,所以一般使用${pageContext.request.contextPath} 定位资源。