9

<%@ 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>

这是我的代码,当输入税然后在按钮之后单击其设置为税并打印税但是当我输入“税”然后在输入框中将值设置为税,同时打印正确的“税”我也想设置输入框值“税”当我采取点击后输入“税”请帮助

4

2 回答 2

13

你有两个:

name="firstinput" 

name="fname"

对于相同的输入字段!

更新:除此之外,更改:

value=<%=request.getParameter("firstinput") %>>

到:

value='<%=request.getParameter("firstinput")%>' />
于 2013-08-10T07:05:47.157 回答
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>
于 2013-08-10T07:19:23.723 回答