今天看了看spring对于视图解析的源码,发现还不是那些思想,internalResourceView里的一个渲染方法
protected void exposeModelAsRequestAttributes(Map<String, Object> model, HttpServletRequest request) throws Exception { for (Map.Entry<String, Object> entry : model.entrySet()) { String modelName = entry.getKey(); Object modelValue = entry.getValue(); if (modelValue != null) { request.setAttribute(modelName, modelValue); if (logger.isDebugEnabled()) { logger.debug("Added model object ‘" + modelName + "‘ of type [" + modelValue.getClass().getName() + "] to request in view with name ‘" + getBeanName() + "‘"); } } else { request.removeAttribute(modelName); if (logger.isDebugEnabled()) { logger.debug("Removed model object ‘" + modelName + "‘ from request in view with name ‘" + getBeanName() + "‘"); } } }} 这个方法就是对视图的渲染,所谓jsp也无非就是对java代码的解释,所以不得不佩服这样简洁的渲染
时间: 2024-10-26 15:26:56