Controller 层 跳转到另一页面

1:  respose:

   index2.jsp 在webContent目录下

    resp.sendRedirect("../index2.jsp");

2: request:

        request.setAttribute("name", "ftian");
       request.getRequestDispatcher("../index2.jsp").forward(request, resp);

  页面EL表达式取值:

      
     

hello world12345!


       name:${requestScope.name }
   

3:ModelAndView

public ModelAndView  testJson(HttpServletRequest request,HttpServletResponse resp) throws Exception, IOException{
		String name = request.getParameter("name");
		System.out.println("name:"+name);
		Map map = new HashMap();
		map.put("ok","okjson");
		String json = JSON.toJSONString(map);
		System.out.println("json:"+json);
	
		//resp.getWriter().println("hello HttpServletResponse");
	    	
	    //resp.sendRedirect("../index2.jsp");
		 //   request.setAttribute("name", "ftian");
	    //	request.getRequestDispatcher("../index2.jsp").forward(request, resp);
		 ModelAndView mv =   new ModelAndView();
		 mv.addObject("name","beijing");
         mv.setViewName("index2");//跳转到jsp的名称index2.jsp   目录为web-info
		 return mv;
		
	}

页面EL表达式取值:

      
     

hello world12345!


       name:${requestScope.name }
   

你可能感兴趣的:(jquery)