public class xxx extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setAttribute("aa", "ok");
response.sendRedirect("/Finish.jsp");
}
}我在Finish.jsp页面里的
<%
String name=(String) request.getAttribute("aa");
%>
怎么为空啊?STRUTS里的ACTION不也是Servlet吗?
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setAttribute("aa", "ok");
response.sendRedirect("/Finish.jsp");
}
}我在Finish.jsp页面里的
<%
String name=(String) request.getAttribute("aa");
%>
怎么为空啊?STRUTS里的ACTION不也是Servlet吗?
<jsp:forward page="http://xxx.com/b.php"/>这个是服务器端跳转,保持当前请求状态的页面跳转 不对的地方,欢迎大家批评,共同学习
所以用 request 是得不到值的 可以用session或用forword 的来指向一个页面,这个是转发 是同一请求
RequestDispatcher rd = request.getRequestDispatcher("/Finish.jsp");
rd.forward(request, response);要转发请求请用这个重定向
request.setAttribute("aa", "ok");
RequestDispatcher rd = request.getRequestDispatcher("/Finish.jsp");
rd.forward(request, response);少写了个语句