in MVC controller, for example

Java代码
  1. TestController extends MultiActionController



1. 转到空白页面

Java代码
  1. public ModelAndView testMVC(HttpServletRequest req,HttpServletResponse res) throws Exception {
  2. return null;
  3. }



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

Java代码
  1. public ModelAndView testMVC(HttpServletRequest req,HttpServletResponse res) throws Exception {
  2. res.getOutputStream().write(new String("testString").getBytes());
  3. return null;
  4. }



3. 转到系统错误页面
3.1 forward to one jsp and set the HTTP_STATUS in jsp file :

Java代码
  1. <%
  2. response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
  3. %>



3.2 set the HTTP_STATUS in MVC Controller.

Java代码
  1. public ModelAndView testMVC(HttpServletRequest req,HttpServletResponse res) throws Exception {
  2. res.setStatus(401);
  3. return null;
  4. }