将jsp中的文本字符串值传递给java类字符串变量 [英] pass a text string value in jsp into a java class string variable
本文介绍了将jsp中的文本字符串值传递给java类字符串变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public class Hello{
String str="";
public static void main(String []args){
}
}
//This is my view
<html
<body>
<input type =text name="urltext">
<input type="button" name="btn">
</body>
</html>
My question is when i click the button What i given in textbox it will assign to String str.Please help me out.
推荐答案
使用scriplet(即< %%>)在jsp页面中编写java代码
use scriplet (i.e <%%>) for writing java code in jsp page
<html
<body>
<form method="post">
<input type =text name="urltext">
<input type="Submit" name="btn" value="submit">
<%
String txtbox=request.getParameter("urltext");
String btn1=request.getParameter("btn");
if(btn1!=null)
{
out.println(txtbox);
}
%>
</body>
</html>
这篇关于将jsp中的文本字符串值传递给java类字符串变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文