Java Jsp中如何设置输入框的值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18159480/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to set value of Input Box in Jsp
提问by Anil Kumar
<%@ 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>
Ths is My code when Put Input tax then after Button click its set to tax and Print Tax But when I tax Input "tax" then Value set to tax in Input Box while Print correct "tax" i want to set input Box value also "tax" when I take Input "tax" after click please help
这是我的代码,当输入输入税然后在按钮单击其设置为税并打印税但是当我对输入“税”征税时,然后将值设置为输入框中的税,同时打印正确的“税”我也想设置输入框值“税”当我拿走点击后输入“税”请帮忙
采纳答案by alfasin
You have both:
你有两个:
name="firstinput"
and
和
name="fname"
for the same input field!
对于相同的输入字段!
UPDATE:In addition to that, change:
更新:除此之外,更改:
value=<%=request.getParameter("firstinput") %>>
to:
到:
value='<%=request.getParameter("firstinput")%>' />
回答by Atul Darne
Its working fine dude
它的工作很好的家伙
<%@ 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>