JSP内置对象:使用getparameter方法获得数据

xiaoxiao2021-02-28  74

新建了两个 jsp页面:Login.jsp 和Index.jsp。 Login.jsp用来填写数据,然后将数据传给index.jsp。

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>信息输入</title> </head> <body> <form action="Index.jsp"> 用户名:<input type="text" name="Username"/><br> 密码:<input type="password" name="Password"/><br> <input type="submit" value="确定"/> </form> </body> </html>

Index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>欢迎登陆</title> </head> <body> <% String name=request.getParameter("Username"); String pwd=request.getParameter("Password"); out.print("name"+name+"pwd"+pwd); %> </body> </html>
转载请注明原文地址: https://www.6miu.com/read-66536.html

最新回复(0)