瀏覽器訪問Servlet1。html
Servlet1想讓Servlet2爲客戶端服務。java
Servlet1調用sendRedirect()方法,將客戶端的請求重定向到Servlet2。瀏覽器
瀏覽器訪問Servlet2。app
Servlet2對客戶端的請求作出響應。spa
瀏覽器訪問Servlet1。code
Servlet1想讓Servlet2對客戶端的請求進行響應,因而調用forward()方法,將請求轉發給Servlet2進行處理。htm
Servlet2對請求作出響應。io
@RequestMapping("/testredirt") public void testredirt(String redirt ,HttpServletRequest request,HttpServletResponse response)throws WeixinException{ try { response.sendRedirect("test.html?redirt="+redirt); } catch (IOException e) { ResultModel obj = new ResultModel("1111","重定向錯誤",""); ResponseTool.exceptionReturn(logger, obj, request, response); } }