使用jsp实现表单与服务器简单交互
程序员文章站
2024-03-20 16:40:16
...
<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<html>
<head>
<title>交互demo</title>
</head>
<body>
<form action="input.jsp" method="post"><!-- action属性规定当提交表单时,向何处发送表单数据。-->
<input type="text" name="name">
<input type="submit" value="显示姓名">
</form>
</body>
</html>
<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<html>
<head>
<title>交互jsp</title>
</head>
<body>
<%
String str = request.getParameter("name");
out.println("姓名:"+str);
%>
</body>
</html>
action属性将表达提交给input.jsp。input.jsp将显示指定内容