东莞网站开发哪里找,什么是网站维护中,临海企业网站建设公司,wordpress中文注册之前的案例#xff0c;我们发现request域中的值可以传到jsp页面中#xff0c;也就是通过视图解析器跳转到视图的底层是请求转发。 如果我们跳转时不想使用视图解析器#xff0c;可以使用原生HttpServletRequest进行请求转发或HttpServletResponse进行重定向#xff1a; Req… 之前的案例我们发现request域中的值可以传到jsp页面中也就是通过视图解析器跳转到视图的底层是请求转发。 如果我们跳转时不想使用视图解析器可以使用原生HttpServletRequest进行请求转发或HttpServletResponse进行重定向 RequestMapping(/c2/hello8)
public void myForward1(HttpServletRequest request, HttpServletResponse response) throws Exception{request.setAttribute(name,666);// 请求转发// request.getRequestDispatcher(/c2/h9).forward(request,response);// 原生重定向response.sendRedirect(/c2/h9);
} 但是SpringMvc其实还有一种更简单的请求转发和重定向的写法 RequestMapping(/c2/h9)
public String myForward3(HttpServletRequest request){request.setAttribute(name,66);// 请求转发return forward:/c2/h10;// 重定向// return redirect:/c2/h10;
}