就很纳闷为什么form里面的页面转跳不了呢,不报错
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="ban.jsp" method="post" >
<input type="text" name="one">
<input type="text" name="two">
<input type="text" name="three">
<input type="button" name="launch" value="发射">
</form>
</body>
</html>
换成 type="submit"试试
【以下回答由 GPT 生成】
问题的根本原因是form中的发射按钮使用了<input type="button">
,而应该使用<input type="submit">
。<input type="button">
是一个普通的按钮,它不会触发表单的提交和页面跳转。正确的代码如下:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="ban.jsp" method="post">
<input type="text" name="one">
<input type="text" name="two">
<input type="text" name="three">
<input type="submit" name="launch" value="发射">
</form>
</body>
</html>
这样修改后,当点击"发射"按钮后,页面将会跳转到ban.jsp
页面,并且将表单中的数据作为POST请求的参数传递给ban.jsp
页面。注意,ban.jsp
页面需要存在于你的项目中,并且处理这些参数的逻辑应该在ban.jsp
中实现。如果ban.jsp
不是一个实际存在的页面,你需要替换成一个真实存在的页面的路径。
【相关推荐】