JSP--第十三天

来源:互联网 发布:js 多功能日历插件 编辑:程序博客网 时间:2024/05/21 17:52

跳转页面:

1 a 标签

2 form表单

3 location.href

4 response.sendR..

 

页面跳转:

1 重定向:

特点:(1) 跳转的路径会发生变化

      (2) 会丢失request保存的数据

response.sendRedirect("页面");

     

2 转发:

特点:(1) 跳转的路径不会发生变化

(2) 不会丢失request保存的数据

 

 request.getRequestDispatcher("页面").forward(request, response);

 

http://localhost:8080/test2/test/a.jsp

 

http://localhost:8080/test2/test/b.jsp

 

 

关于保存:

request.setAttribute("",);

关于获取

request.getAttribute("")

 

关于?传参

<a href=”xxx.jsp?变量=”></a>

注意:值只能是String或者数字

如果传的是中文,则需要转码:

 

如果需要传多个参数,则通过& 来传递

?x1=a&x2=b......

 


原创粉丝点击