JSP之表单提交get和post的区别详解及实例
作者:lqh 时间:2024-03-26 09:06:39
JSP之表单提交get和post的详解及实例
一 get和post的区别
二 实战(post方式提交)
1、login.jsp
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>" rel="external nofollow" rel="external nofollow" >
<title>My JSP 'login.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css" rel="external nofollow" rel="external nofollow" >
-->
</head>
<body>
<h1>用户登录</h1>
<hr>
<form action="dologin.jsp" name="loginForm" method="post">
<table>
<tr>
<td>用户名:</td>
<td><input type="text" name="username"/></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" name="password"/></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="登录"></td>
</tr>
</table>
</form>
</body>
</html>
2、dologin.jsp
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>" rel="external nofollow" rel="external nofollow" >
<title>My JSP 'dologin.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css" rel="external nofollow" rel="external nofollow" >
-->
</head>
<body>
<h1>登录成功</h1>
<hr>
</body>
</html>
三 运行结果
如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
来源:http://cakin24.iteye.com/blog/2394400
标签:JSP,get,post
0
投稿
猜你喜欢
Python使用numpy产生正态分布随机数的向量或矩阵操作示例
2022-12-28 05:44:11
Python2.7简单连接与操作MySQL的方法
2024-01-25 18:38:56
python结合shell自动创建kafka的连接器实战教程
2023-01-06 19:17:13
Python实现获取网页内容及自动填表单与登录功能
2023-10-23 23:55:27
asp如何做一个看他爱不爱你的小测验?
2010-07-11 21:16:00
Python同步遍历多个列表的示例
2023-08-08 00:20:10
python中__call__内置函数用法实例
2022-06-04 11:46:32
用一个案例讲解SQL Server数据库恢复
2008-11-28 14:17:00
详解python爬虫系列之初识爬虫
2023-11-21 04:09:41
教你使用Python的pygame模块实现拼图游戏
2022-06-28 03:20:20
Persits AspJpeg 1.8+ 轻松实现透明文字去锯齿水印
2009-03-20 14:03:00
js全选/全不选/反选 checkbox代码
2008-03-18 13:00:00
让ASP也支持动态include文件
2008-05-08 13:00:00
php链式操作mysql数据库(封装类带使用示例)
2023-05-25 02:58:22
Python计算信息熵实例
2022-08-17 16:13:39
学习ASP.NET八天入门:第二天
2007-08-07 13:24:00
使用python实现抓取中国银行外汇牌价首页数据实现
2021-11-28 02:05:49
Python3 类型标注支持操作
2021-12-25 05:39:41
Python字符串常用方法以及其应用场景详解
2022-02-15 18:39:53
将Python脚本打包成exe文件
2021-06-08 12:21:55