冰枫逸范
Victory won’t come to me unless I go to it. 胜利是不会向我走来的,我必须自己走向胜利。
JSP中提交参数除了使用表单,也可以直接在地址栏提交,这种方法叫做“地址重写”。
1.jsp
 1 <%@page contentType="text/html;charset=GB2312" %>
 2 <%
 3      request.setCharacterEncoding("GB2312");
 4 %>
 5 
 6 <html>
 7   <head>
 8     <title>1.jsp</title>
 9   </head>
10   
11   <body>
12       <%         
13           String Name=request.getParameter("name");
14       %>
15       <h1>内容:<%=Name %></h1>
16   </body>
17 </html>
直接在地址栏输入:http://localhost/web/request/1.jsp?name=zxm
就可以显示结果。

如果传递多个参数,可以这样输入地址:localhost/web/request/1.jsp?name=zxm&password=123
posted on 2008-04-06 13:53 冰枫逸范 阅读(527) 评论(1)  编辑  收藏

FeedBack:
# re: JSP地址重写
2008-11-26 21:30 | 详细信息
.......
地址重写不是这样的,地址重新是本来
localhost/web/request/1.jsp?name=zxm&password=123
这样访问,现在重写为
localhost/web/request/1_name@zxm_password@123.htm
这种了。这个叫地址重写,比如Spring mvc默认建立的页面在WEB-INF/jsp/index.jsp
但是重写后访问就是http://localhost/xxx/index.htm  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: