用户名:rghgxj
客户端跳转//使用response对象的sendR仍财元调攻些岩向edirect实现客户端跳转//servlet掌护节的doGet方法更香河publicvoiddoGet(h**ttpSer学是送胜制跑亚vletRequestreq,h**ttpServletResponse来自res)throwsServletException,IOException{PrintWriterout=res.getWriter();out.println("h**elloworld!");res.sendRedirect("***.do");//servlet实现跳转(客...客户端跳转
//使用response对象的sendRedirect实现客户端跳转
//servlet的doGet方法
publicvoi担奏ddoGet(h**ttpServletRequestreq,h**ttpServletRe问答sponseres)
th协送怎验之任道货rowsServletException,IOException{
PrintWriterout=res.getWriter();
out.println("h**elloworld!");
res.sendRedirect("***.d宪讲特云完游布粒听o");//servlet实现跳转(客户端跳转)
}
客户端跳转不能像目标页面传递参数(如果使用该方法非要向目标页面传递参数的话,可以雨血英掌陈冲名季虽使用session对象将参数值记录
服务器端跳转
//使用RequestDispatcher接口实海起践青号助下量做现服务器端跳转,且向目标页面传递参数
publicvoiddoGet(h**ttpServletRequestre料干换局主q,h**ttpServletResponseresp)
throwsServletException,
IOException{
PrintWriterout=resp.编模消问振具伯还史势浓getWriter()烧重呢亮露如频;
/*
*在servlet美中实现服务器端跳转,并向跳转页面传递参数
*/
req.setAttrib秋送蒸门须ute("name","haiyun");//为request对象添加参数
RequestD玉沙风示粒指ispatcherdispatcher=req.getR井很粒底味技参空功以从equestDispatcher("test-04.jsp");//使用req对象获取RequestDispatcher对象
dispatcher.forward(req,resp);//使用RequestDispatcher对象在服务器端向格应供去子优飞举果李加目的路径跳转
}全部