请教,这个页面为何无法跳转
请问,这个页面为何无法跳转?
上一个页面在文本框中输入内容,提交后插入数据库,这部分都可以成功,而且数据的更新一切正常,但是为何无法转入index的第一页,请大神指教。
package servlet;
import database.DBConnector;
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*;
import dto.Information;
public class AddInfor extends HttpServlet {
public AddInfor() { }
@Override
public void destroy() {super.destroy();} //重写destroy方法
@Override
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException{
doPost(request,response); // 将Get请求转发至doPost
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
HttpSession session=request.getSession();
Information information=null ;
if(request.getParameter( name )==null||request.getParameter( subject )==null) //,,,,,
session.removeAttribute( information );
else{
information= new Information();
information.setSubject(request.getParameter( subject ));
information.setContent(request.getParameter( content ));
information.setName(request.getParameter( name ));
information.setEmail(request.getParameter( email ));
information.add();
session.setAttribute( information ,information);
}
//在这个地方无法跳转,不知道怎么回事。。。
response.sendRedirect( /Websource/index.jsp?page=1 ); //请求跳转至主页
}
public void init() throws ServletException{ } //重写init方法
}
------最佳解决
方案
气瓶 现场处置方案 .pdf气瓶 现场处置方案 .doc见习基地管理方案.doc关于群访事件的化解方案建筑工地扬尘治理专项方案下载
--------------------------------------------------------
response.sendRedirect( /Websource/index.jsp?page=1 );用这个写一个简单的测试。看下
路径什么的有没有问题。测试类能跳转的话,再找其他地方。
------其他解决方案--------------------------------------------------------
return new ActionForward( /Websource/index.jsp?page=1 );
要不试试这个,
------其他解决方案--------------------------------------------------------
相对路径写全试试 response.sendRedirect( ../Websource/index.jsp?page=1 );
------其他解决方案--------------------------------------------------------
如果跳转这个语句没有执行,那就是你前面代码出来问题。
------其他解决方案--------------------------------------------------------
information.add();这个是什么,add什么东西,这个方法里是不是有没执行的
------其他解决方案--------------------------------------------------------
页面无法跳转的话,情况可能有多种:
1.你先确定这句代码有没有执行;
2.如果执行了,无法跳转,看该页面是否报错~
------其他解决方案--------------------------------------------------------
你用绝对路径试试 ~~~
------其他解决方案--------------------------------------------------------
是没转,还是转了404,,
------其他解决方案--------------------------------------------------------
引用:
你用绝对路径试试 ~~~
绝对路径也不行...
------其他解决方案--------------------------------------------------------
引用:
页面无法跳转的话,情况可能有多种:
1.你先确定这句代码有没有执行;