版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_41690324/article/details/83341857
题目分析:
题目分析:
从第一个jsp中传值,然后第二个jsp根据传过来的数显示图片,数为多少就显示多少个图片
第一个jsp
<%@ 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>img</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">
</head>
<body>
<form action="/FridayJob/Task/Task03/img_action.jsp" method="post">
<input type="text" name="num"><input type="submit">
</form>
</body>
</html>
第二个jsp
<%@ 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>img_action</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">
</head>
<body>
<h1>传值接收值按所传数据显示图片</h1>
<%
int number = Integer.parseInt(request.getParameter("num"));
%>
<%
for (int i = 0; i < number; i++) {
%>
<img src="/FridayJob/Task/Task03/panda.png">
<%
}
%>
</body>
</html>