Spring源码片断

MarshallingView对视图进行渲染的代码
	protected void renderMergedOutputModel(Map<String, Object> model, 
										   HttpServletRequest request, 
										   HttpServletResponse response) throws Exception {
		Object toBeMarshalled = locateToBeMarshalled(model);
		if (toBeMarshalled == null) {
			throw new ServletException("Unable to locate object to be marshalled in model: " + model);
		}
		ByteArrayOutputStream bos = new ByteArrayOutputStream(2048);
		marshaller.marshal(toBeMarshalled, new StreamResult(bos));

		response.setContentType(getContentType());
		response.setContentLength(bos.size());

		FileCopyUtils.copy(bos.toByteArray(), response.getOutputStream());
	}

猜你喜欢

转载自stamen.iteye.com/blog/1543921