request对象
获取请求参数值
在一个请求中可以通过使用“?”的方式来传递参数,然后通过request对象的get Parameter()方法来获取参数的值。
1、首先在web项目中创建index.jsp页面,在其中加入一个超链接按钮,用来请求show.jsp页面,并在请求后增加一个参数id。其实就是在<body>与<\body>之间加入这样一句代码:
<a href="show.jsp? id=001">获取请求参数的值<\a>
2、然后新建show.jsp页面,在其中通过getParameter()方法来获取id参数与name参数的值,并将其输出到页面中。
3、运行结果如图
总结:如果charset后面是ISO-8859-1,代码就运行不出来,会显示错误原因:Some characters can't be mapped using ISO-8859-1 character encoding.Either change the encoding or remove the characters which are not supported by the " ISO-8859-1" character encoding.
将ISO-8859-1改成UTF-8,就能运行出来。