springmvc中使用response的out.print问题

阅读更多
public ModelAndView handleRequest(HttpServletRequest request,
		HttpServletResponse response) throws Exception {
	Member member = (Member) RequestUtil.parseRequestToObject(request,Member.class);
	if (member == null) {
		jzLogic.insertMember(member);
		return new ModelAndView("index");
	} else {
		return new ModelAndView("Error", "message", "账号已被注册!");
	}
}

在上述代码中如果需要使用out.print打印如alert("");信息可按以下方式进行:
......
	response.setContentType("text/html; charset=gbk");
	PrintWriter out = response.getWriter(); 
	out.println(""); 
	return null;
......

return null,如果return new ModelAndView则直接转发

你可能感兴趣的:(HTML)