当前位置: 代码迷 >> J2SE >> 不用dispatcher怎么转发request
  详细解决方案

不用dispatcher怎么转发request

热度:83   发布时间:2016-04-24 13:00:56.0
不用dispatcher如何转发request
不能用RequestDispatcher,因为是点击jsp1提交转到jsp2的,如何在jsp2里获取jsp1保存的对象?
jsp1:
HTML code
<%@ page contentType="text/html; charset=GBK" %><html><head><title>jsp1</title></head><%request.setAttribute("str","hello");%><body bgcolor="#ffffff"><form name="form1" method="post" action="jsp2.jsp">  <input type="text" name="textfield" id="textfield">  <input type="submit" name="button" id="button" value="提交"></form></body></html>



jsp2
HTML code
<%@ page contentType="text/html; charset=GBK" %><html><head><title>jsp2</title></head><body bgcolor="#ffffff"><h1><%=request.getAttribute("str").toString()%></h1></body></html>


------解决方案--------------------
<input type="hidden" name="str" value="hello">
放 jsp1 的 form 中。
------解决方案--------------------
探讨
<input type="hidden" name="str" value="hello">
放 jsp1 的 form 中。
  相关解决方案