kavinhub 发表于 2013-2-3 14:09:09

SpringMVC

in MVC controller, for example
TestController extends MultiActionController

1. 转到空白页面

public ModelAndView testMVC(HttpServletRequest req,HttpServletResponse res) throws Exception {return null;}

2. 转到空白页面,并打印字符

public ModelAndView testMVC(HttpServletRequest req,HttpServletResponse res) throws Exception {res.getOutputStream().write(new String("testString").getBytes());return null;}

3. 转到系统错误页面
3.1 forward to one jsp and set the HTTP_STATUS in jsp file :
<%response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);%>

3.2 set the HTTP_STATUS in MVC Controller.
public ModelAndView testMVC(HttpServletRequest req,HttpServletResponse res) throws Exception {res.setStatus(401);return null;}

4. Redirect in Spring MVC
public ModelAndView testMVC(HttpServletRequest req,HttpServletResponse res) throws Exception {String view = "redirect:"+redirectPath; -- redirectPaht must including the "http://"return new ModelAndView(view, model);}
页: [1]
查看完整版本: SpringMVC