<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<html>
<form action="index.jsp">
<body>
First INPUT:
<input name="firstinput" type="text" value=<%=request.getParameter( "firstinput") %>>
<br>
<input type="submit" value="Submit">
<% String first = request.getParameter("firstinput");
out.println(first); %>
</body>
</form>
</html>
这是我的代码当放入输入税然后按钮单击其设置为税和打印税但当我税输入“税”然后值设置为输入框中的税,而打印正确的“税”我想设置输入框当我点击请输入“税”后请点“请”帮助
答案 0 :(得分:8)
你们俩都有:
name="firstinput"
和
name="fname"
用于相同的输入字段!
更新:除此之外,请更改:
value=<%=request.getParameter("firstinput") %>>
为:
value='<%=request.getParameter("firstinput")%>' />
答案 1 :(得分:1)
工作正常的老兄
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="index.jsp" method="get">
First INPUT:
<input name="firstinput" type="text" value=<%=request.getParameter("firstinput") %>>
<br>
<input type="submit" value="Submit">
<%
String first = request.getParameter("firstinput");
out.println(first);
%>
</form>
</body>
</html>