3.8web网页设计的一篇作业
2017-03-09 08:44 迷蒙的天空 阅读(440) 评论(0) 编辑 收藏 举报我今天学习了如何从一个网页跳转到另一个网页,首先我做了第一个页面Homework,在这个页面运行后会出现一个输入数字的文本框,再点击提交后,会跳转到另一个页面并比较与你指定数比较大小
第一个网页:Homework
<%@ page language="java" import="java.util.*" pageEncoding="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%>">
<title>My JSP 'homework.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">
-->
</head>
<body>
<form name="forml"method="post"action="answer.jsp">
数字:
<label>
<input type="test" name="number"id="textfield">
<br>
<input type="submit"name="button"id="button"value="提交">
</label>
</form>
</body>
</html>
第二个网页:Answer
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%String Num ; %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'answer.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">
-->
</head>
<body>
<% Num = request.getParameter("number"); %>
<%
Integer.valueOf(Num);
if(Integer.valueOf(Num)>=10) {
%>
<%=+Integer.valueOf(Num)+">=10" %>
<%
}else{
%>
<%=+Integer.valueOf(Num)+"<10" %>
<%
}
%>
</body>
</html>
下面附赠几张截图: