将变量分配给 HTML 中的值
String registration="10-120";
<input type="text" name="registrationUpdate" value="Reg#" maxlength="50" /><br>
上面的 value="Reg#"
是硬代码。 我想将变量分配给该值。即均值=注册;
更新我!
String registration="10-120";
<input type="text" name="registrationUpdate" value="Reg#" maxlength="50" /><br>
In the above , value="Reg#"
which is hard code.
I want to assign variable to the value. i.e. Means value=registration;
update me!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的问题不是很清楚。我假设该变量是在 servlet 内部声明的,因为在 JSP 中使用 Java 是不好的做法。为了能够在转发到 JSP 的 Servlet 之间共享变量,您需要将此变量设置为请求属性:
然后在 JSP 中,您可以使用 JSP EL 获取“注册”属性的值
:应该阅读 Java EE 教程:http://docs.oracle.com/javaee/5/tutorial/doc/bnadp.html
Your question is not very clear. I'll assume the variable is declared inside a servlet, because it's bad practice to use Java in a JSP. To be able to share a variable between a Servlet whic forwards to a JSP, you need to set this variable into a request attribute:
And then in the JSP, you can get the value of the "registration" attribute using the JSP EL:
You should read the Java EE tutorial: http://docs.oracle.com/javaee/5/tutorial/doc/bnadp.html
非常简单
希望这会帮助你
itz very simple
hope this will help you