main.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>测试</title>
</head>
<body>
<form action="action.jsp" method="post" name="form">
<table>
<tr><td>request是干嘛的?</td></tr>
<tr>
<td>
<input type="radio" name="1" value=1>A.响应请求
<input type="radio" name="1" value=2>B.取得数据与信息
<input type="radio" name="1" value=3>C.输出数据
<input type="radio" name="1" value=4>D.钝角
</td>
</tr>
<tr><td><br>respond是干嘛的?</td></tr>
<tr>
<td>
<input type="radio" name="2" value=1>A.响应客户端信息
<input type="radio" name="2" value=2>B.数据导入
<input type="radio" name="2" value=3>C.表示当前网页
<input type="radio" name="2" value=4>D.数据输出
</td>
</tr>
<tr><td><br>下列那个属于9个内置对象</td></tr>
<tr>
<td>
<input type="radio" name="3" value=1>A.out
<input type="radio" name="3" value=2>B.int
<input type="radio" name="3" value=3>C.forward
<input type="radio" name="3" value=4>D.post
</td>
</tr>
<tr>
<td><input type="submit" name="submit" value="开始传输"></td>
</tr>
</table>
</form>
</body>
</html>
action.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.lang.Math"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>计算结果</title>
</head>
<body>
<%!int a=0; %>
<%
a=0;
String t1=request.getParameter("1");
String t2=request.getParameter("2");
String t3=request.getParameter("3");
if(Integer.parseInt(t1)==2) a++;
if(Integer.parseInt(t2)==1) a++;
if(Integer.parseInt(t3)==1) a++;
%>
<p>正确答案:1.B 2.A 3.A
<P>你的选择:1.<%= (char) (64 + Integer.parseInt(t1)) %>
2.<%= (char) (64 + Integer.parseInt(t2)) %>
3.<%= (char) (64 + Integer.parseInt(t3)) %>
<br>
<%="正确题数:"+a %>
</body>
</html>
执行效果
通过form中的action进行页面的跳转和数据的传递
标签:干嘛,jsp,测试,action,数据,问卷 From: https://www.cnblogs.com/fyall/p/18486556