request.getparameter方法怎么从jsp中获取数据

如题所述

我来举个例子,可以写一个form表单,然后把值填入进去:

对应的jsp代码:

<form action="getValue.jsp" method="GET">
站点名:<input type="text" name="name"> <br /> 
网址:<input type="text" name="url"> <br />
<input type="submit" value="提交">
</form>


以下是:getValue.jsp的代码,运行如上图所示

<body>
<%request.setCharacterEncoding("GBK");

String name=request.getParameter("name");%>
<%String url=request.getParameter("url"); %>

<h1>获取数据</h1>
<u1>
<li><p>
<b>站点名:</b>
<%=name%>
</p></li>
<li><p>
<b>网址:</b>
<%=url%>
</p></li>
</u1>
</body>

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答