您现在的位置是:首页 > 编程 > 

SpringMVC源码解析

2025-07-27 06:50:12
SpringMVC源码解析 一、主要组件DispatcherServlet:前端控制器,统一处理请求和响应,整个流程控制的中心,由它调用其他组件处理用户请求。HandlerMapping:处理器映射器,根据请求的url、method等信息查Handler,及控制器方法Handler:处理器,及Controller方法,具体业务实现HandlerAdpter:处理器适配器,对处理器方法进行执行Vi

SpringMVC源码解析

一、主要组件

  • DispatcherServlet:前端控制器,统一处理请求和响应,整个流程控制的中心,由它调用其他组件处理用户请求。
  • HandlerMapping:处理器映射器,根据请求的url、method等信息查Handler,及控制器方法
  • Handler:处理器,及Controller方法,具体业务实现
  • HandlerAdpter:处理器适配器,对处理器方法进行执行
  • ViewRsolver:视图解析器,进行视图解析,如ThymeleafView、InternalResourceView
  • View:视图,及页面

二、DispatcherServlet初始化过程

1)结构体系

Servlet接口init初始化方法

代码语言:javascript代码运行次数:0运行复制
public interface Servlet {
    void init(ServletConfig var1) throws ServletException;
}

GenericServlet抽象类,初始化方法空实现(由子类重写实现)

代码语言:javascript代码运行次数:0运行复制
public abstract class GenericServlet implements Servlet, ServletConfig, Serializable {
    public void init(ServletConfig config) throws ServletException {
         = config;
        this.init();
    }
    public void init() throws ServletException {
    }
}

GenericServlet抽象类的子类HttpServlet没有实现,具体实现在HttpServletBean类 根据代码可知,具体实现依然需要子类根据需求喜好自己实现重写

代码语言:javascript代码运行次数:0运行复制
public abstract class HttpServletBean extends HttpServlet implements EnvironmentCapable, EnvironmentAware {
	@Override
	public final void init() throws ServletException {
		//让子类做他们喜欢的任何初始化
		initServletBean();
	}
	protected void initServletBean() throws ServletException {
	}
}

FrameworkServlet 抽象类重写初始化方法initServletBean() ‘springMVC’ :项目名称。日志打印初始化servlet名称以及初始化所需时间

代码语言:javascript代码运行次数:0运行复制
public abstract class FrameworkServlet extends HttpServletBean implements ApplicationContextAware {
	@Override
	protected final void initServletBean() throws ServletException {
		//日志打印Initializing Spring DispachServlet 'springMVC'
		getServletContext().log("Initializing Spring " + getClass().getSimpleame() + " '" + getServletame() + "'");
		if (logger.isInfoEnabled()) {
			//日志打印Initializing Servlet 'springMVC'
			logger.info("Initializing Servlet '" + getServletame() + "'");
		}
		long startTime = ();
		try {
			//初始化容器
			this.webApplicationContext = initWebApplicationContext();
			//空实现,由子类重写
			initFrameworkServlet();
		}
		catch (ServletException | RuntimeException ex) {
			("Context initialization failed", ex);
			throw ex;
		}
		//记录初始化所需时间
		if (logger.isInfoEnabled()) {
			logger.info("Completed initialization in " + (() - startTime) + " ms");
		}
	}
}

初始化webApplicationContext容器

代码语言:javascript代码运行次数:0运行复制
protected WebApplicationContext initWebApplicationContext() {
	WebApplicationContext rootContext =
			WebApplicationContextUtils.getWebApplicationContext(getServletContext());
	WebApplicationContext wac = null;

	if (this.webApplicationContext != null) {
		//上下文实例在构造时被注入->使用它
		wac = this.webApplicationContext;
		if (wac instanceof ConfigurableWebApplicationContext) {
			ConfigurableWebApplicationContext cwac = (ConfigurableWebApplicationContext) wac;
			if (!cwac.isActive()) {
				// The context has not yet been refreshed -> provide services such as
				// setting the parent context, setting the application context id, etc
				if (cwac.getParent() == null) {
					// The context instance was injected without an explicit parent -> set
					// the root application context (if any; may be null) as the parent
					cwac.setParent(rootContext);
				}
				configureAndRefreshWebApplicationContext(cwac);
			}
		}
	}
	if (wac == null) {
		// o context instance was injected at ctruction time -> see if one
		// has been registered in the servlet context. If one exists, it is assumed
		// that the parent context (if any) has already been set and that the
		// user has performed any initialization such as setting the context id
		wac = findWebApplicationContext();
	}
	if (wac == null) {
		//创建WebApplicationContext
		wac = createWebApplicationContext(rootContext);
	}

	if (!this.refreshEventReceived) {
		//创建WebApplicationContext时候会添加,onRefreash,DispatcherServlet初始化九大组件
		synchronized () {
			onRefresh(wac);
		}
	}

	if (this.publishContext) {
		// Publish the context as a servlet context attribute.
		String attrame = getServletContextAttributeame();
		getServletContext().setAttribute(attrame, wac);
	}

	return wac;
}

创建WebApplicationContext XmlWebApplication类的父类实现了ConfigurableWebApplicationContext接口 WebApplicationContext的父容器是ApplicationContext

代码语言:javascript代码运行次数:0运行复制
protected WebApplicationContext createWebApplicationContext(@ullable ApplicationContext parent) {
	//默认XmlWebApplication
	Class<?> contextClass = getContextClass();
	if (!isAssignableFrom(contextClass)) {
		throw new ApplicationContextException(
				"Fatal initialization error in servlet with name '" + getServletame() +
				"': custom WebApplicationContext class [" + contextClass.getame() +
				"] is not of type ConfigurableWebApplicationContext");
	}
	//调用无参构造函数创建  ConfigurableWebApplicationContext 
	ConfigurableWebApplicationContext wac =
			(ConfigurableWebApplicationContext) BeanUtils.instantiateClass(contextClass);
	//设置环境参数
	wac.setEnvironment(getEnvironment());
	//设置springmvc的WebApplicationContext容器的父容器为spring的ApplicationContext容器 
	wac.setParent(parent);
	String configLocation = getContextConfigLocation();
	if (configLocation != null) {
		//设置‘springmvc.xml’配置文件路径
		wac.setConfigLocation(configLocation);
	}
	//配置刷新容器
	configureAndRefreshWebApplicationContext(wac);
	return wac;
}

配置刷新容器

代码语言:javascript代码运行次数:0运行复制
protected void configureAndRefreshWebApplicationContext(ConfigurableWebApplicationContext wac) {
	if (ObjectUtils.identityToString(wac).equals(wac.getId())) {
		if ( != null) {
			wac.setId();
		}
		else {
            //就是把它的id由org.springframework.support.XmlWebApplicationContext@c5c0c
            //改成了基于Servlet名字的org.springframework.WebApplicationContext:/dispatcher,
            //官方文档说是替换成一个更有意义的ID
			wac.setId(ConfigurableWebApplicationContext.APPLICATIO_COTEXT_ID_PREFIX +
					ObjectUtils.getDisplayString(getServletContext().getContextPath()) + '/' + getServletame());
		}
	}
    //配置ServletContext,放进去的是ApplicationContextFacade对象
	wac.setServletContext(getServletContext());
	//配置ServletConfig,StandardWrapperFacade对象
	wac.setServletConfig(getServletConfig());
	//配置命名空间,默认是[Servlet的名字]-servlet
	wac.setamespace(getamespace());
	//添加,监听ContextRefreshedEvent事件,该事件会在WebApplicationContext初始化完毕或者主动调用
    //refresh()方法时触发,比如Spring容器加载完context配置文件后就会触发,所以会触发多次,触发后调用
	wac.addApplicationListener(new SourceFilteringListener(wac, new ContextRefreshListener()));

	//补全之前创建的StandardServletEnvironment对象
	ConfigurableEnvironment env = wac.getEnvironment();
	if (env instanceof ConfigurableWebEnvironment) {
		((ConfigurableWebEnvironment) env).initPropertySources(getServletContext(), getServletConfig());
	}
	//空方法,也是供子类扩展的,目前还没有使用
	postProcessWebApplicationContext(wac);
	//主要是为了在调用refresh方法之前做一些准备工作
	applyInitializers(wac);
	//主动调用refresh方法,触发上面刚添加的
	wac.refresh();
}

DispatcherServlet初始化初始化九大组件

代码语言:javascript代码运行次数:0运行复制
public class DispatcherServlet extends FrameworkServlet {
    @Override
    protected void onRefresh(ApplicationContext context) {
        //将初始化策略和onRefresh方法分开,让子类灵活扩展
        initStrategies(context);
    }
    //这也正是SpringMVC最为核心的部分
    protected void initStrategies(ApplicationContext context) {
        //处理文件上传请求
        initMultipartResolver(context);
        //国际化处理
        initLocaleResolver(context);
        //解析主题配置
        initThemeResolver(context);
        //把request映射到具体的处理器上(负责handler)
        initHandlerMappings(context);
        //调用处理器来处理(负责让handler干活)
        initHandlerAdapters(context);
        //解析过程出了问题就交给我
        initHandlerExceptionResolvers(context);
        //从request中获取viewame
        initRequestToViewameTranslator(context);
        //将我们返回的视图名字符串(如hello.jsp)解析为具体的view对象
        initViewResolvers(context);
        //管理FlashMap,主要用于redirect
        initFlashMapManager(context);
    }
}
2)通过requestMapping注解(url)获取controller
  • InitializingBean接口
代码语言:javascript代码运行次数:0运行复制
public interface InitializingBean {
    void afterPropertiesSet() throws Exception;
}
  • AbstractHandlerMethodMapping抽象类
代码语言:javascript代码运行次数:0运行复制
public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMapping implements InitializingBean {
	@Override
	public void afterPropertiesSet() {
		initHandlerMethods();
	}
	protected void initHandlerMethods() {
		for (String beaname : getCandidateBeanames()) {
			 判断不是已 scopedTarget 开头
			if (!beaname.startsWith(SCOPED_TARGET_AME_PREFIX)) {
				processCandidateBean(beaname);
			}
		}
		handlerMethodsInitialized(getHandlerMethods());
	}
	//获取所有的bean名字
	protected String[] getCandidateBeanames() {
		return (this.detectHandlerMethodsInAncestorContexts ?
				BeanFactoryUtils.beanamesForTypeIncludingAncestors(obtainApplicationContext(), ) :
				obtainApplicationContext().getBeanamesForType());
	}
	protected void processCandidateBean(String beaname) {
		Class<?> beanType = null;
		try {
			// 获取具体的类型
			beanType = obtainApplicationContext().getType(beaname);
		}
		catch (Throwable ex) {
			// 不是null 并且 类型是存在 @Controller 或者 @RequestMapping  注解
			if (logger.isTraceEnabled()) {
				("Could not resolve type for bean '" + beaname + "'", ex);
			}
		}
		if (beanType != null && isHandler(beanType)) {
			detectHandlerMethods(beaname);
		}
	}
}

核心代码来了

代码语言:javascript代码运行次数:0运行复制
protected void detectHandlerMethods(Object handler) {
	Class<?> handlerType = (handler instanceof String ?
			obtainApplicationContext().getType((String) handler) : handler.getClass());

	if (handlerType != null) {
		Class<?> userType = ClassUtils.getUserClass(handlerType);
		Map<Method, T> methods = MethodIntrospector.selectMethods(userType,
				(MethodIntrospector.MetadataLookup<T>) method -> {
					try {
						return getMappingForMethod(method, userType);
					}
					catch (Throwable ex) {
						throw new IllegalStateException("Invalid mapping on handler class [" +
								userType.getame() + "]: " + method, ex);
					}
				});
		if (logger.isTraceEnabled()) {
			(formatMappings(userType, methods));
		}
		methods.forEach((method, mapping) -> {
			Method invocableMethod = AopUtils.selectInvocableMethod(method, userType);
			registerHandlerMethod(handler, invocableMethod, mapping);
		});
	}
}
总结:

Web容器启动后(发起调用),GenericServlet接收上下文对象,HttpServletBean给属性赋值,FrameworkServlet负责创建并初始化WebApplicationContext容器,最后DispatcherServlet初始化九大组件

三、DispatcherServlet处理请求过程

http://localhost:8080/springmvc/target

代码语言:javascript代码运行次数:0运行复制
protected void doDispatch(HttpServletRequest request, HttpServletRespe respe) throws Exception {
    HttpServletRequest processedRequest = request;
    HandlerExecutionChain mappedHandler = null;
    boolean multipartRequestParsed = false;

    try {
        ModelAndView mv = null;
        Exception dispatchException = null;

        try {
            //检查处理文件上传请求
            processedRequest = checkMultipart(request);
            multipartRequestParsed = (processedRequest != request);

            //处理器映射器,根据url到对应的controller,不到报错
            mappedHandler = getHandler(processedRequest);
			if (mappedHandler == null) {
				noHandlerFound(processedRequest, respe);
				return;
			}
            //根据controller到对应的适配器
            HandlerAdapter ha = getHandlerAdapter(mappedHandler.getHandler());

            String method = request.getMethod();
            boolean isGet = "GET".equals(method);
            if (isGet || "HEAD".equals(method)) {
                //根据文件的最近修改时间判断是否返回04状态码,默认修改时间返回-1即不支持该缓存方式。
                //如果想使用需要另外配置
                long lastModified = ha.getLastModified(request, mappedHandler.getHandler());
                if (new ServletWebRequest(request, respe).checkotModified(lastModified) && isGet) {
                    return;
                }
            }

            //处理前先执行的preHandle方法,该方法会返回一个boolean值
            //如果是true,则交给后面的Interceptor继续处理,返回false则表示自己处理完了,
            //包括respe也搞定了,后面的不用麻烦了直接做中断处理。
            if (!mappedHandler.applyPreHandle(processedRequest, respe)) {
                return;
            }

            //HandlerAdapter调用Handler处理请求
            mv = ha.handle(processedRequest, respe, mappedHandler.getHandler());

            //判断是否需要viewameTranslator从request里获取view的名字(针对在handler的返回值里没有给出的情况)
            applyDefaultViewame(request, mv);
            //处理完后执行的PostHandle方法
            mappedHandler.applyPostHandle(processedRequest, respe, mv);
        }
        catch (Exception ex) {
            dispatchException = ex;
        }
        //做最后的处理工作,比如页面渲染,调用的afterCompletion方法等
        processDispatchResult(processedRequest, respe, mappedHandler, mv, dispatchException);
    }
    catch (Exception ex) {
    }
    finally {
        //清理文件上传留下的临时文件
        if (multipartRequestParsed) {
            cleanupMultipart(processedRequest);
        }
    }
}
2)获取处理器映射器
代码语言:javascript代码运行次数:0运行复制
@ullable
protected HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception {
	if (this.handlerMappings != null) {
		for (HandlerMapping mapping : this.handlerMappings) {
			//通过url匹配controller具体方法
			HandlerExecutionChain handler = mapping.getHandler(request);
			if (handler != null) {
				return handler;
			}
		}
	}
	return null;
}

核心就是第一行代码

代码语言:javascript代码运行次数:0运行复制
@Override
@ullable
public final HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception {
	Object handler = getHandlerInternal(request);
	if (handler == null) {
		handler = getDefaultHandler();
	}
	if (handler == null) {
		return null;
	}
	// Bean name or resolved handler?
	if (handler instanceof String) {
		String handlerame = (String) handler;
		handler = obtainApplicationContext().getBean(handlerame);
	}

	HandlerExecutionChain executionChain = getHandlerExecutionChain(handler, request);

	if (logger.isTraceEnabled()) {
		("Mapped to " + handler);
	}
	else if (logger.isDebugEnabled() && !request.getDispatcherType().equals(DispatcherType.ASYC)) {
		logger.debug("Mapped to " + executionChain.getHandler());
	}

	if (hasCorsConfigurationSource(handler) || CorsUtils.isPreFlightRequest(request)) {
		CorsConfiguration config = getCorsConfiguration(handler, request);
		if (getCorsConfigurationSource() != null) {
			CorsConfiguration globalConfig = getCorsConfigurationSource().getCorsConfiguration(request);
			config = (globalConfig != null ? globalConfigbine(config) : config);
		}
		if (config != null) {
			config.validateAllowCredentials();
		}
		executionChain = getCorsHandlerExecutionChain(request, executionChain, config);
	}

	return executionChain;
}

核心步骤

代码语言:javascript代码运行次数:0运行复制
@Override
protected HandlerMethod getHandlerInternal(HttpServletRequest request) throws Exception {
	//requestMapping地址如  “/target”
	String lookupPath = initLookupPath(request);
	acquireReadLock();
	try {
		//通过九大组件中获取的全量的controller匹配得到具体方法并返回
		HandlerMethod handlerMethod = lookupHandlerMethod(lookupPath, request);
		return (handlerMethod != null ? () : null);
	}
	finally {
		releaseReadLock();
	}
}

结果

2)处理器适配器
代码语言:javascript代码运行次数:0运行复制
public interface HandlerAdapter {
	//是否支持该HandlerMethod
	boolean supports(Object handler);
	//HandlerMthod根据反射调用controller具体方法返回modelAndView
	@ullable
	ModelAndView handle(HttpServletRequest request, HttpServletRespe respe, Object handler) throws Exception;
	//最后修改时间
	long getLastModified(HttpServletRequest request, Object handler);
}
  1. HttpRequestHandler:适配实现了HttpRequestHandler接口的handler
  2. SimpleServletHandlerAdapter:适配实现了Servlet接口的handler
  3. RequestMappingHandlerAdapter:适配通过@RequestMapping注解的handler。会封装为HandleMethod对象
  4. SimpleControllerHandlerAdapter:适配实现了Controller接口的handler

处理器适配器通过反射执行controller方法核心代码

代码语言:javascript代码运行次数:0运行复制
@Override
protected ModelAndView handleInternal(HttpServletRequest request,
		HttpServletRespe respe, HandlerMethod handlerMethod) throws Exception {

	ModelAndView mav;
	//检查是否支持当前request的请求方式和session
	checkRequest(request);

	// 如果需要,在同步块中执行invokeHandlerMethod
	if (this.synchronizeOnSession) {
		HttpSession session = request.getSession(false);
		if (session != null) {
			Object mutex = WebUtils.getSessionMutex(session);
			synchronized (mutex) {
				mav = invokeHandlerMethod(request, respe, handlerMethod);
			}
		}
		else {
			// o HttpSession available -> no mutex necessary
			mav = invokeHandlerMethod(request, respe, handlerMethod);
		}
	}
	else {
		// o synchronization on session demanded at all...
		mav = invokeHandlerMethod(request, respe, handlerMethod);
	}

	if (!(HEADER_CACHE_COTROL)) {
		//判断是否有@SessionAttribute注解
		if (getSessionAttributesHandler(handlerMethod).hasSessionAttributes()) {
			applyCacheSeconds(respe, );
		}
		else {
			//准备响应工作
			prepareRespe(respe);
		}
	}

	return mav;
}

调用具体方法

代码语言:javascript代码运行次数:0运行复制
public void invokeAndHandle(ServletWebRequest webRequest, ModelAndViewContainer mavContainer,
		Object... providedArgs) throws Exception {
	Object returnValue = invokeForRequest(webRequest, mavContainer, providedArgs);
	...
}

最难也是最主要的工作获取方法反射需要的参数(及方法请求的参数)

代码语言:javascript代码运行次数:0运行复制
@ullable
public Object invokeForRequest(ativeWebRequest request, @ullable ModelAndViewContainer mavContainer, Object... providedArgs) throws Exception {
    Object[] args = this.getMethodArgumentValues(request, mavContainer, providedArgs);
    if (logger.isTraceEnabled()) {
        ("Arguments: " + (args));
    }
    return this.doInvoke(args);
}

获取request、sesion、自定义对象等等参数值

代码语言:javascript代码运行次数:0运行复制
protected Object[] getMethodArgumentValues(ativeWebRequest request, @ullable ModelAndViewContainer mavContainer, Object... providedArgs) throws Exception {
    MethodParameter[] parameters = this.getMethodParameters();
    if (ObjectUtils.isEmpty(parameters)) {
        return EMPTY_ARGS;
    } else {
        Object[] args = new Object[parameters.length];

        for(int i = 0; i < parameters.length; ++i) {
            MethodParameter parameter = parameters[i];
            parameter.initParameterameDiscovery(this.parameterameDiscoverer);
            args[i] = findProvidedArgument(parameter, providedArgs);
            if (args[i] == null) {
                if (!this.resolvers.supportsParameter(parameter)) {
                    throw new IllegalStateException(formatArgumentError(parameter, "o suitable resolver"));
                }

                try {
                    args[i] = this.resolvers.resolveArgument(parameter, mavContainer, request, this.dataBinderFactory);
                } catch (Exception var10) {
                    if (logger.isDebugEnabled()) {
                        String exMsg = var10.getMessage();
                        if (exMsg != null && !(parameter.getExecutable().toGenericString())) {
                            logger.debug(formatArgumentError(parameter, exMsg));
                        }
                    }

                    throw var10;
                }
            }
        }

        return args;
    }
}
)视图渲染

执行最后结果

代码语言:javascript代码运行次数:0运行复制
private void processDispatchResult(HttpServletRequest request, HttpServletRespe respe,
		@ullable HandlerExecutionChain mappedHandler, @ullable ModelAndView mv,
		@ullable Exception exception) throws Exception {

	boolean errorView = false;
	//如果有异常,通过异常处理器处理
	if (exception != null) {
		if (exception instanceof ModelAndViewDefiningException) {
			logger.debug("ModelAndViewDefiningException encountered", exception);
			mv = ((ModelAndViewDefiningException) exception).getModelAndView();
		}
		else {
			Object handler = (mappedHandler != null ? mappedHandler.getHandler() : null);
			mv = processHandlerException(request, respe, handler, exception);
			errorView = (mv != null);
		}
	}

	// 处理渲染
	if (mv != null && !mv.wasCleared()) {
		render(mv, request, respe);
		if (errorView) {
			(request);
		}
	}
	else {
		if (logger.isTraceEnabled()) {
			("o view rendering, null ModelAndView returned.");
		}
	}

	if (WebAsyncUtils.getAsyncManager(request).isConcurrentHandlingStarted()) {
		// Concurrent handling started during a forward
		return;
	}

	if (mappedHandler != null) {
		// ,页面渲染后调用
		(request, respe, null);
	}
}

具体渲染过程

代码语言:javascript代码运行次数:0运行复制
protected void render(ModelAndView mv, HttpServletRequest request, HttpServletRespe respe) throws Exception {
	// 国际化设置
	Locale locale = (this.localeResolver != null ? this.localeResolver.resolveLocale(request) : request.getLocale());
	respe.setLocale(locale);

	View view;
	String viewame = mv.getViewame();
	if (viewame != null) {
		// 获取视图解析器
		view = resolveViewame(viewame, mv.getModelInternal(), locale, request);
		if (view == null) {
			throw new ServletException("Could not resolve view with name '" + mv.getViewame() +
					"' in servlet with name '" + getServletame() + "'");
		}
	}
	else {
		// o need to lookup: the ModelAndView object contains the actual View object.
		view = mv.getView();
		if (view == null) {
			throw new ServletException("ModelAndView [" + mv + "] neither contains a view name nor a " +
					"View object in servlet with name '" + getServletame() + "'");
		}
	}

	// Delegate to the View object for rendering.
	if (logger.isTraceEnabled()) {
		("Rendering view [" + view + "] ");
	}
	//
	try {
		if (mv.getStatus() != null) {
			respe.setStatus(mv.getStatus().value());
		}
		//将model值渲染到页面上
		view.render(mv.getModelInternal(), request, respe);
	}
	catch (Exception ex) {
		if (logger.isDebugEnabled()) {
			logger.debug("Error rendering view [" + view + "]", ex);
		}
		throw ex;
	}
}

view = resolveViewame(viewame, mv.getModelInternal(), locale, request); 通过自己配置的视图解析器,

view.render(mv.getModelInternal(), request, respe); 将model值渲染到页面上

总结
  • DispatcherServlet中处理器映射器通过@RequestMapping注解到对应的Controller方法
  • DispatcherServlet中处理器适配器拿着处理器映射器数据通过反射执行Controller方法并返回ModelAndView
  • DispatcherServlet中最后执行结果处理,通过配置的视图解析器为ModelAndView添加前缀后缀,再将model填充页面返回即可
  • ,执行Controller方法的前者方法,后置方法,渲染页面返回后执行的方法
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。 原始发表:2022-12-11,如有侵权请联系 cloudcommunity@tencent 删除渲染容器对象配置源码

#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格

本文地址:http://www.dnpztj.cn/biancheng/1162920.html

相关标签:无
上传时间: 2025-07-20 20:42:26
留言与评论(共有 16 条评论)
本站网友 洛阳三维地图
2分钟前 发表
具体实现依然需要子类根据需求喜好自己实现重写代码语言:javascript代码运行次数:0运行复制public abstract class HttpServletBean extends HttpServlet implements EnvironmentCapable
本站网友 肾上腺疲劳
27分钟前 发表
the ModelAndView object contains the actual View object. view = mv.getView(); if (view == null) { throw new ServletException("ModelAndView [" + mv + "] neither contains a view name nor a " + "View object in servlet with name '" + getServletame() + "'"); } } // Delegate to the View object for rendering. if (logger.isTraceEnabled()) { ("Rendering view [" + view + "] "); } // try { if (mv.getStatus() != null) { respe.setStatus(mv.getStatus().value()); } //将model值渲染到页面上 view.render(mv.getModelInternal()
本站网友 桥西租房
6分钟前 发表
mavContainer
本站网友 支气管扩张
26分钟前 发表
respe
本站网友 microsoft中国
5分钟前 发表
respe).checkotModified(lastModified) && isGet) { return; } } //处理前先执行的preHandle方法
本站网友 下阴
26分钟前 发表
主要用于redirect initFlashMapManager(context); } }2)通过requestMapping注解(url)获取controllerInitializingBean接口代码语言:javascript代码运行次数:0运行复制public interface InitializingBean { void afterPropertiesSet() throws Exception; }AbstractHandlerMethodMapping抽象类代码语言:javascript代码运行次数:0运行复制public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMapping implements InitializingBean { @Override public void afterPropertiesSet() { initHandlerMethods(); } protected void initHandlerMethods() { for (String beaname
本站网友 天津滨海新区房价
5分钟前 发表
具体实现依然需要子类根据需求喜好自己实现重写代码语言:javascript代码运行次数:0运行复制public abstract class HttpServletBean extends HttpServlet implements EnvironmentCapable
本站网友 牙科医生
3分钟前 发表
根据请求的url
本站网友 lottery
29分钟前 发表
mv
本站网友 挂钟风水
22分钟前 发表
sesion
本站网友 上海神州租车
14分钟前 发表
invocableMethod
本站网友 湖北自贸区
26分钟前 发表
); } else { //准备响应工作 prepareRespe(respe); } } return mav; }调用具体方法代码语言:javascript代码运行次数:0运行复制public void invokeAndHandle(ServletWebRequest webRequest
本站网友 买房首付
24分钟前 发表
由它调用其他组件处理用户请求
本站网友 铁岭美食
25分钟前 发表
及Controller方法
本站网友 alpha测试
27分钟前 发表
exception); errorView = (mv != null); } } // 处理渲染 if (mv != null && !mv.wasCleared()) { render(mv