in MVC controller, for example

Java代码 复制代码 收藏代码
  1. TestController extends MultiActionController
TestController extends MultiActionController



1. 转到空白页面

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



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

Java代码 复制代码 收藏代码
  1. public ModelAndView testMVC(HttpServletRequest req,HttpServletResponse res) throws Exception {
  2. res.getOutputStream().write(new String("testString").getBytes());
  3. return null;
  4. }
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 :

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



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. }
public ModelAndView testMVC(HttpServletRequest req,HttpServletResponse res) throws Exception {		
		res.setStatus(401);
		return null;
}