<%@page contentType="text/html; charset=GB2312"%>
<html>
<head>
<title>
form.jsp file
</title>
</head>
<body style="background-color:lightblue">
<h2 style="font-family:arial;color:red;font-size:25px;text-align:center">登录页面</h2>
<form action="result.jsp" method="get" align="center">
姓名:<input type="text" name="name" size="20" value="" maxlength="20"><br/>
密码:<input type="password" name="password" size="20" value="" maxlength="20"><br/>
<!--在爱好前空一个空格,是为了排版好看些-->
爱好:<input type="checkbox" name="hobby" value="唱歌">唱歌
<input type="checkbox" name="hobby" value="足球">足球
<input type="checkbox" name="hobby" value="篮球">篮球<br/><br/>
<input type="submit" name="submit" value="登录">
<input type="reset" name="reset" value="重置"><br/>
</form>
</body>
</html>
<%@page language="java" import="java.util.*" pageEncoding="GB2312"%>
<html>
<head>
<title>
result.jsp file
</title>
</head>
<body bgcolor="ffffff">
<%
request.setCharacterEncoding("GB2312");
String name=request.getParameter("name");
name=new String(name.getBytes("iso-8859-1"),"GB2312");
String pwd=request.getParameter("password");
String[] hobby=request.getParameterValues("hobby");//注意这里的函数是getParameterValues()接受一个数组的数据
%>
<%
if(!name.equals("") && !pwd.equals(""))
{
%>
您好!登录成功!<br/>
姓名:<%=name%><br/>
密码:<%=pwd%><br/>
爱好:<%
for(String ho: hobby)
{
ho=new String(ho.getBytes("iso-8859-1"),"GB2312");
out.print(ho+" ");
}
%>
<%
}
else
{
%>
请输入姓名或密码!
<%
}
%>
</body>
</html>
<%@page contentType="text/html; charset=GB2312"%>
<html>
<head>
<title>
set.jsp file
</title>
</head>
<body style="background-color:lightblue">
<%
request.setAttribute("name","心雨");
%>
<jsp:forward page="get.jsp"/>
</body>
</html>
<%@page contentType="text/html; charset=GB2312"%>
<html>
<head>
<title>
get.jsp file
</title>
</head>
<body style="background-color:lightblue">
<%
out.println("传递过来的参数是:"+request.getAttribute("name"));
%>
</body>
</html>
<%@page contentType="text/html; charset=GB2312"%>
<html>
<head>
<title>
href.jsp file
</title>
</head>
<body style="background-color:lightblue">
<a href="getHerf.jsp?name=心雨&password=123" rel="external nofollow" >传递参数</a>
</body>
</html>
<%@page contentType="text/html; charset=GB2312"%>
<html>
<head>
<title>
getHref.jsp file
</title>
</head>
<body style="background-color:lightblue">
<%
String name=request.getParameter("name");
name=new String(name.getBytes("iso-8859-1"),"gb2312");
out.print("name:"+name);
%>
<br/>
<%
out.print("password:"+request.getParameter("password"));
%>
</body>
</html>
<%@page contentType="text/html; charset=GB2312"%>
<html>
<head>
<title>
param.jsp file
</title>
</head>
<body style="background-color:lightblue">
<%request.setCharacterEncoding("GB2312");%>
<jsp:forward page="getParam.jsp">
<jsp:param name="name" value="心雨"/>
<jsp:param name="password" value="123"/>
</jsp:forward>
</body>
</html>
<%@page contentType="text/html; charset=GB2312"%>
<html>
<head>
<title>
getParam.jsp file
</title>
</head>
<body style="background-color:lightblue">
<%
String name=request.getParameter("name");
out.print("name:"+name);
%>
<br/>
<%
out.print("password:"+request.getParameter("password"));
%>
</body>
</html>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有