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());
	}

你可能感兴趣的:(spring)