springMVC(尚硅谷笔记)

阅读: 评论:0

2024年2月1日发(作者:)

springMVC(尚硅谷笔记)

public void setLastName(String lastName) { me = lastName; } public String getEmail() { return email; } public void setEmail(String email) { = email; } public Integer getGender() { return gender; } public void setGender(Integer gender) { = gender; } public Employee(Integer id, String lastName, String email, Integer gender) { super(); = id; me = lastName; = email; = gender; } public Employee() { }}准备dao模拟数据package

import

import

import

import

import

Collection;HashMap;Map;Employee;Repository;;@Repositorypublic class EmployeeDao { private static Map employees = null;

static{ employees = new HashMap(); (1001, new Employee(1001, "E-AA", "**********", 1)); (1002, new Employee(1002, "E-BB", "**********", 1)); (1003, new Employee(1003, "E-CC", "**********", 0)); (1004, new Employee(1004, "E-DD", "**********", 0)); (1005, new Employee(1005, "E-EE", "**********", 1)); }

private static Integer initId = 1006;

public void save(Employee employee){ if(() == null){ (initId++); } ((), employee);

@Overrideprotected void doService(HttpServletRequest request, HttpServletResponse response) throws Exception { logRequest(request); // Keep a snapshot of the request attributes in case of an include, // to be able to restore the original attributes after the include. Map attributesSnapshot = null; if (udeRequest(request)) { attributesSnapshot = new HashMap<>(); Enumeration<?> attrNames = ributeNames(); while (eElements()) { String attrName = (String) ement(); if (pAfterInclude || With(DEFAULT_STRATEGIES_PREFIX)) { (attrName, ribute(attrName)); } } } // Make framework objects available to handlers and view objects. ribute(WEB_APPLICATION_CONTEXT_ATTRIBUTE, getWebApplicationContext()); ribute(LOCALE_RESOLVER_ATTRIBUTE, Resolver); ribute(THEME_RESOLVER_ATTRIBUTE, esolver); ribute(THEME_SOURCE_ATTRIBUTE, getThemeSource()); if (apManager != null) { FlashMap inputFlashMap = veAndUpdate(request, response); if (inputFlashMap != null) { ribute(INPUT_FLASH_MAP_ATTRIBUTE, fiableMap(inputFlashMap)); } ribute(OUTPUT_FLASH_MAP_ATTRIBUTE, new FlashMap()); ribute(FLASH_MAP_MANAGER_ATTRIBUTE, apManager); } RequestPath requestPath = null; if (equestPath && !sedRequestPath(request)) { requestPath = ndCache(request); } try { //

处理请求和响应 doDispatch(request, response); } finally { if (!ncManager(request).isConcurrentHandlingStarted()) { // Restore the original attribute snapshot, in case of an include. if (attributesSnapshot != null) { restoreAttributesAfterInclude(request, attributesSnapshot); } } if (requestPath != null) { arsedRequestPath(request); } }}c>doDispatch()所在类:cherServletprotected void doDispatch(HttpServletRequest request, HttpServletResponse response) throws Exception { HttpServletRequest processedRequest = request; HandlerExecutionChain mappedHandler = null; boolean multipartRequestParsed = false; WebAsyncManager asyncManager = ncManager(request);

triggerAfterCompletion(processedRequest, response, mappedHandler, ex); } catch (Throwable err) { triggerAfterCompletion(processedRequest, response, mappedHandler, new NestedServletException("Handler processing failed", err)); } finally { if (urrentHandlingStarted()) { // Instead of postHandle and afterCompletion if (mappedHandler != null) { fterConcurrentHandlingStarted(processedRequest, response); } } else { // Clean up any resources used by a multipart request. if (multipartRequestParsed) { cleanupMultipart(processedRequest); } } }}d>processDispatchResult()

springMVC(尚硅谷笔记)

本文发布于:2024-02-01 01:40:51,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170672285132928.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:模拟   请求   笔记   数据   处理
留言与评论(共有 0 条评论)
   
验证码:
排行榜

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23