从Servlet的重定向 [英] Redirect from Servlet
问题描述
ObjectInputStream in = new ObjectInputStream((InputStream) request.getInputStream());
List<Double> al=(List<Double>)in.readObject();
in.close();
for(int x=0;x<al.size();x++)
{
System.out.println("List");
System.out.println(al.get(x));
}
System.out.println("going to demo.jsp");
response.sendRedirect("demo.jsp");
我写一个客户端服务器程序。我从Android手机发送一个ArrayList,我能够接受的名单中还,但在那之后我想这个servlet重定向到demo.jsp,但它只是不会重定向。试着用的RequestDispatcher了。请帮忙。我在哪里去了?
I am writing a client server program. I am sending an arraylist from an android phone and i am able to receive the list also but after that I want the servlet to redirect to demo.jsp but it just wont redirect. Tried with requestdispatcher too. Please help. Where am I going wrong?
编辑:这是servlet code,它是在doPost方法
this is the servlet code and it is in the doPost method.
推荐答案
我张贴这个答案,因为一个得票最多使我误入歧途。从一个servlet重定向,你只需做到这一点:
I'm posting this answer because the one with the most votes led me astray. To redirect from a servlet, you simply do this:
response.sendRedirect("simpleList.do")
在这个特殊的问题,我想@MD正确地解释了为什么提问者是有他的问题,但由于这是当你搜索从Servlet的重定向谷歌的第一个结果,我认为有一个答案是很重要的帮助大多数人,而不仅仅是原来的提问者。
In this particular question, I think @M-D is correctly explaining why the asker is having his problem, but since this is the first result on google when you search for "Redirect from Servlet" I think it's important to have an answer that helps most people, not just the original asker.
这篇关于从Servlet的重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!