diff --git a/.gitignore b/.gitignore
index fd4141c434c7ee0844950221d475c38b19df0b38..ecf48537113a5e76539aa0bb01c2a68c2bc183b4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,4 @@
/.idea/**/*.xml
/code/**/target/**/*
/.idea/**/*.iml
+/code/simple-spring-boot/simple-spring-boot.iml
diff --git a/code/mvc/pom.xml b/code/mvc/pom.xml
deleted file mode 100644
index a10771229ac044e9fe0ca3e332e33f7f2516aa23..0000000000000000000000000000000000000000
--- a/code/mvc/pom.xml
+++ /dev/null
@@ -1,80 +0,0 @@
-
-
-
- 4.0.0
-
- com.lagou.edu
- mvc
- 1.0-SNAPSHOT
- war
-
- mvc Maven Webapp
-
- http://www.example.com
-
-
- UTF-8
- 8
- 8
-
-
-
-
- junit
- junit
- 4.12
- test
-
-
-
-
- javax.servlet
- javax.servlet-api
- 3.1.0
- provided
-
-
-
- org.apache.commons
- commons-lang3
- 3.9
-
-
-
-
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.1
-
- 8
- 8
- utf-8
-
-
- -parameters
-
-
-
-
-
-
- org.apache.tomcat.maven
- tomcat7-maven-plugin
- 2.2
-
- 8080
- /
-
-
-
-
-
diff --git a/code/mvc/src/main/java/com/lagou/demo/controller/DemoController.java b/code/mvc/src/main/java/com/lagou/demo/controller/DemoController.java
deleted file mode 100644
index bf612f2e45c1d050e963a7e489629b543134a915..0000000000000000000000000000000000000000
--- a/code/mvc/src/main/java/com/lagou/demo/controller/DemoController.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.lagou.demo.controller;
-
-import com.lagou.demo.service.IDemoService;
-import com.lagou.edu.mvcframework.annotations.LagouAutowired;
-import com.lagou.edu.mvcframework.annotations.LagouController;
-import com.lagou.edu.mvcframework.annotations.LagouRequestMapping;
-import com.lagou.edu.mvcframework.annotations.Security;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-@LagouController
-@LagouRequestMapping("/demo")
-@Security(value = "admin")
-public class DemoController {
-
-
- @LagouAutowired
- private IDemoService demoService;
-
-
- /**
- * URL: /demo/query?name=lisi
- * @param request
- * @param response
- * @param name
- * @return
- */
- @LagouRequestMapping("/query")
- public String query(HttpServletRequest request, HttpServletResponse response,String name) {
- return demoService.get(name);
- }
-
- @LagouRequestMapping("/getOnlyByUser1")
- @Security(value = "user1")
- public String getOnlyByUser1(HttpServletRequest request, HttpServletResponse response,String name) {
- return demoService.getOnlyByUser1(name);
- }
-
- @LagouRequestMapping("/getOnlyByUser2")
- @Security(value = "user2")
- public String getOnlyByUser2(HttpServletRequest request, HttpServletResponse response,String name) {
- return demoService.getOnlyByUser2(name);
- }
-}
diff --git a/code/mvc/src/main/java/com/lagou/demo/service/IDemoService.java b/code/mvc/src/main/java/com/lagou/demo/service/IDemoService.java
deleted file mode 100644
index cdaa480f518121e9abd303ad9640ef85dce969c9..0000000000000000000000000000000000000000
--- a/code/mvc/src/main/java/com/lagou/demo/service/IDemoService.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.lagou.demo.service;
-
-public interface IDemoService {
-
- String get(String name);
-
- String getOnlyByUser1(String name);
-
- String getOnlyByUser2(String name);
-}
diff --git a/code/mvc/src/main/java/com/lagou/demo/service/impl/DemoServiceImpl.java b/code/mvc/src/main/java/com/lagou/demo/service/impl/DemoServiceImpl.java
deleted file mode 100644
index 45aafddb171355f87930963b5e3402113a455194..0000000000000000000000000000000000000000
--- a/code/mvc/src/main/java/com/lagou/demo/service/impl/DemoServiceImpl.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.lagou.demo.service.impl;
-
-import com.lagou.demo.service.IDemoService;
-import com.lagou.edu.mvcframework.annotations.LagouService;
-
-@LagouService("demoService")
-public class DemoServiceImpl implements IDemoService {
- @Override
- public String get(String name) {
- System.out.println("service 实现类中的name参数:" + name) ;
- return name;
- }
-
- @Override
- public String getOnlyByUser1(String name) {
- return get(name);
- }
-
- @Override
- public String getOnlyByUser2(String name) {
- return get(name);
- }
-}
diff --git a/code/mvc/src/main/java/com/lagou/edu/mvcframework/annotations/LagouAutowired.java b/code/mvc/src/main/java/com/lagou/edu/mvcframework/annotations/LagouAutowired.java
deleted file mode 100644
index 8e10a01777a18a48ff0902890b884f9b07db170d..0000000000000000000000000000000000000000
--- a/code/mvc/src/main/java/com/lagou/edu/mvcframework/annotations/LagouAutowired.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.lagou.edu.mvcframework.annotations;
-
-import java.lang.annotation.*;
-
-@Documented
-@Target(ElementType.FIELD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface LagouAutowired {
- String value() default "";
-}
diff --git a/code/mvc/src/main/java/com/lagou/edu/mvcframework/annotations/LagouController.java b/code/mvc/src/main/java/com/lagou/edu/mvcframework/annotations/LagouController.java
deleted file mode 100644
index 5022b35e1e81fb3ad3a5d0e395f81c40eae6cf45..0000000000000000000000000000000000000000
--- a/code/mvc/src/main/java/com/lagou/edu/mvcframework/annotations/LagouController.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.lagou.edu.mvcframework.annotations;
-
-import java.lang.annotation.*;
-
-@Documented
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface LagouController {
- String value() default "";
-}
diff --git a/code/mvc/src/main/java/com/lagou/edu/mvcframework/annotations/LagouRequestMapping.java b/code/mvc/src/main/java/com/lagou/edu/mvcframework/annotations/LagouRequestMapping.java
deleted file mode 100644
index f075c513973f5f06b17e71b971173595e2e96eaf..0000000000000000000000000000000000000000
--- a/code/mvc/src/main/java/com/lagou/edu/mvcframework/annotations/LagouRequestMapping.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.lagou.edu.mvcframework.annotations;
-
-import java.lang.annotation.*;
-
-@Documented
-@Target({ElementType.TYPE,ElementType.METHOD})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface LagouRequestMapping {
- String value() default "";
-}
diff --git a/code/mvc/src/main/java/com/lagou/edu/mvcframework/annotations/LagouService.java b/code/mvc/src/main/java/com/lagou/edu/mvcframework/annotations/LagouService.java
deleted file mode 100644
index c7214fc64214bfb4043d324f89c55faa1aa6f7c1..0000000000000000000000000000000000000000
--- a/code/mvc/src/main/java/com/lagou/edu/mvcframework/annotations/LagouService.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.lagou.edu.mvcframework.annotations;
-
-import java.lang.annotation.*;
-
-@Documented
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface LagouService {
- String value() default "";
-}
diff --git a/code/mvc/src/main/java/com/lagou/edu/mvcframework/annotations/Security.java b/code/mvc/src/main/java/com/lagou/edu/mvcframework/annotations/Security.java
deleted file mode 100644
index 32d2d7d65cacdfad90d23592ef0bf28208e4b59e..0000000000000000000000000000000000000000
--- a/code/mvc/src/main/java/com/lagou/edu/mvcframework/annotations/Security.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.lagou.edu.mvcframework.annotations;
-
-import java.lang.annotation.*;
-
-@Documented
-@Target(value = {ElementType.TYPE , ElementType.METHOD})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Security {
- String[] value();
-}
diff --git a/code/mvc/src/main/java/com/lagou/edu/mvcframework/exception/SecurityException.java b/code/mvc/src/main/java/com/lagou/edu/mvcframework/exception/SecurityException.java
deleted file mode 100644
index df0e6dc7b78dbf7a3277e0ac4cc74fc64874b9c9..0000000000000000000000000000000000000000
--- a/code/mvc/src/main/java/com/lagou/edu/mvcframework/exception/SecurityException.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.lagou.edu.mvcframework.exception;
-
-public class SecurityException extends Throwable {
- private Integer code;
-
- private String msg;
-
- public SecurityException() {
- }
-
- public SecurityException(Integer code, String msg) {
- this.code = code;
- this.msg = msg;
- }
-
- public Integer getCode() {
- return code;
- }
-
- public void setCode(Integer code) {
- this.code = code;
- }
-
- public String getMsg() {
- return msg;
- }
-
- public void setMsg(String msg) {
- this.msg = msg;
- }
-}
diff --git a/code/mvc/src/main/java/com/lagou/edu/mvcframework/pojo/Handler.java b/code/mvc/src/main/java/com/lagou/edu/mvcframework/pojo/Handler.java
deleted file mode 100644
index 0b6d074d066c2543efe3b182ec230f400eb65583..0000000000000000000000000000000000000000
--- a/code/mvc/src/main/java/com/lagou/edu/mvcframework/pojo/Handler.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package com.lagou.edu.mvcframework.pojo;
-
-import javax.sound.midi.MetaEventListener;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Pattern;
-
-
-/**
- * 封装handler方法相关的信息
- */
-public class Handler {
-
- private Object controller; // method.invoke(obj,)
-
- private Method method;
-
- private Pattern pattern; // spring中url是支持正则的
-
- private Map paramIndexMapping; // 参数顺序,是为了进行参数绑定,key是参数名,value代表是第几个参数
-
- private Set allowedUserSet = new HashSet<>();
-
- public Set getAllowedUserSet() {
- return allowedUserSet;
- }
-
- public Handler(Object controller, Method method, Pattern pattern) {
- this.controller = controller;
- this.method = method;
- this.pattern = pattern;
- this.paramIndexMapping = new HashMap<>();
- }
-
- public Object getController() {
- return controller;
- }
-
- public void setController(Object controller) {
- this.controller = controller;
- }
-
- public Method getMethod() {
- return method;
- }
-
- public void setMethod(Method method) {
- this.method = method;
- }
-
- public Pattern getPattern() {
- return pattern;
- }
-
- public void setPattern(Pattern pattern) {
- this.pattern = pattern;
- }
-
- public Map getParamIndexMapping() {
- return paramIndexMapping;
- }
-
- public void setParamIndexMapping(Map paramIndexMapping) {
- this.paramIndexMapping = paramIndexMapping;
- }
-}
diff --git a/code/mvc/src/main/java/com/lagou/edu/mvcframework/servlet/LgDispatcherServlet.java b/code/mvc/src/main/java/com/lagou/edu/mvcframework/servlet/LgDispatcherServlet.java
deleted file mode 100644
index 06cf76d4c32cc4d0647ed733258b84479a571df9..0000000000000000000000000000000000000000
--- a/code/mvc/src/main/java/com/lagou/edu/mvcframework/servlet/LgDispatcherServlet.java
+++ /dev/null
@@ -1,418 +0,0 @@
-package com.lagou.edu.mvcframework.servlet;
-
-import com.lagou.edu.mvcframework.exception.SecurityException;
-import com.lagou.edu.mvcframework.annotations.*;
-import com.lagou.edu.mvcframework.pojo.Handler;
-import org.apache.commons.lang3.StringUtils;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Parameter;
-import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class LgDispatcherServlet extends HttpServlet {
-
-
- private Properties properties = new Properties();
-
- private List classNames = new ArrayList<>(); // 缓存扫描到的类的全限定类名
-
- // ioc容器
- private Map ioc = new HashMap();
-
-
- // handlerMapping
- //private Map handlerMapping = now HashMap<>(); // 存储url和Method之间的映射关系
- private List handlerMapping = new ArrayList<>();
-
- @Override
- public void init(ServletConfig config) throws ServletException {
- // 1 加载配置文件 springmvc.properties
- String contextConfigLocation = config.getInitParameter("contextConfigLocation");
- doLoadConfig(contextConfigLocation);
-
- // 2 扫描相关的类,扫描注解
- doScan(properties.getProperty("scanPackage"));
-
-
- // 3 初始化bean对象(实现ioc容器,基于注解)
- doInstance();
-
- // 4 实现依赖注入
- doAutoWired();
-
- // 5 构造一个HandlerMapping处理器映射器,将配置好的url和Method建立映射关系
- initHandlerMapping();
-
- System.out.println("lagou mvc 初始化完成....");
-
- // 等待请求进入,处理请求
- }
-
- /*
- 构造一个HandlerMapping处理器映射器
- 最关键的环节
- 目的:将url和method建立关联
- */
- private void initHandlerMapping() {
- if(ioc.isEmpty()) {return;}
-
- for(Map.Entry entry: ioc.entrySet()) {
- // 获取ioc中当前遍历的对象的class类型
- Class> aClass = entry.getValue().getClass();
-
-
- if(!aClass.isAnnotationPresent(LagouController.class)) {continue;}
-
-
- String baseUrl = "";
- if(aClass.isAnnotationPresent(LagouRequestMapping.class)) {
- LagouRequestMapping annotation = aClass.getAnnotation(LagouRequestMapping.class);
- baseUrl = annotation.value(); // 等同于/demo
- }
-
- String[] controllerAllowedUsers = new String[]{};
- if(aClass.isAnnotationPresent(Security.class)) {
- Security annotation = aClass.getAnnotation(Security.class);
- controllerAllowedUsers = annotation.value();
- }
-
- // 获取方法
- Method[] methods = aClass.getMethods();
- for (int i = 0; i < methods.length; i++) {
- Method method = methods[i];
-
- // 方法没有标识LagouRequestMapping,就不处理
- if(!method.isAnnotationPresent(LagouRequestMapping.class)) {continue;}
-
- // 如果标识,就处理
- LagouRequestMapping annotation = method.getAnnotation(LagouRequestMapping.class);
- String methodUrl = annotation.value(); // /query
- String url = baseUrl + methodUrl; // 计算出来的url /demo/query
-
- // 把method所有信息及url封装为一个Handler
- Handler handler = new Handler(entry.getValue(),method, Pattern.compile(url));
-
-
- // 计算方法的参数位置信息 // query(HttpServletRequest request, HttpServletResponse response,String name)
- Parameter[] parameters = method.getParameters();
- for (int j = 0; j < parameters.length; j++) {
- Parameter parameter = parameters[j];
-
- if(parameter.getType() == HttpServletRequest.class || parameter.getType() == HttpServletResponse.class) {
- // 如果是request和response对象,那么参数名称写HttpServletRequest和HttpServletResponse
- handler.getParamIndexMapping().put(parameter.getType().getSimpleName(),j);
- }else{
- handler.getParamIndexMapping().put(parameter.getName(),j); //
- }
-
- }
-
- addUser(handler.getAllowedUserSet() , controllerAllowedUsers);
- if(method.isAnnotationPresent(Security.class)) {
- Security annotationSecurity = method.getAnnotation(Security.class);
- addUser(handler.getAllowedUserSet() , annotationSecurity.value());
- }
-
- // 建立url和method之间的映射关系(map缓存起来)
- handlerMapping.add(handler);
-
- }
-
-
- }
-
- }
-
- private void addSecurityUser(Set allowedUserSet, String[] controllerAllowedUsers, String[] value) {
- if (controllerAllowedUsers.length > 0){
- addUser(allowedUserSet , controllerAllowedUsers);
- }
-
- if (value.length > 0){
- addUser(allowedUserSet , value);
- }
- }
-
- private void addUser(Set allowedUserSet, String[] controllerAllowedUsers) {
- if (controllerAllowedUsers == null || controllerAllowedUsers.length <1){
- return;
- }
- for (String user : controllerAllowedUsers){
- allowedUserSet.add( user );
- }
- }
-
- // 实现依赖注入
- private void doAutoWired() {
- if(ioc.isEmpty()) {return;}
-
- // 有对象,再进行依赖注入处理
-
- // 遍历ioc中所有对象,查看对象中的字段,是否有@LagouAutowired注解,如果有需要维护依赖注入关系
- for(Map.Entry entry: ioc.entrySet()) {
- // 获取bean对象中的字段信息
- Field[] declaredFields = entry.getValue().getClass().getDeclaredFields();
- // 遍历判断处理
- for (int i = 0; i < declaredFields.length; i++) {
- Field declaredField = declaredFields[i]; // @LagouAutowired private IDemoService demoService;
- if(!declaredField.isAnnotationPresent(LagouAutowired.class)) {
- continue;
- }
-
-
- // 有该注解
- LagouAutowired annotation = declaredField.getAnnotation(LagouAutowired.class);
- String beanName = annotation.value(); // 需要注入的bean的id
- if("".equals(beanName.trim())) {
- // 没有配置具体的bean id,那就需要根据当前字段类型注入(接口注入) IDemoService
- beanName = declaredField.getType().getName();
- }
-
- // 开启赋值
- declaredField.setAccessible(true);
-
- try {
- declaredField.set(entry.getValue(),ioc.get(beanName));
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- }
-
- }
-
-
- }
-
-
-
-
- }
-
-
- // ioc容器
- // 基于classNames缓存的类的全限定类名,以及反射技术,完成对象创建和管理
- private void doInstance() {
-
- if(classNames.size() == 0) return;
-
- try{
-
- for (int i = 0; i < classNames.size(); i++) {
- String className = classNames.get(i); // com.lagou.demo.controller.DemoController
-
- // 反射
- Class> aClass = Class.forName(className);
- // 区分controller,区分service'
- if(aClass.isAnnotationPresent(LagouController.class)) {
- // controller的id此处不做过多处理,不取value了,就拿类的首字母小写作为id,保存到ioc中
- String simpleName = aClass.getSimpleName();// DemoController
- String lowerFirstSimpleName = lowerFirst(simpleName); // demoController
- Object o = aClass.newInstance();
- ioc.put(lowerFirstSimpleName,o);
- }else if(aClass.isAnnotationPresent(LagouService.class)) {
- LagouService annotation = aClass.getAnnotation(LagouService.class);
- //获取注解value值
- String beanName = annotation.value();
-
- // 如果指定了id,就以指定的为准
- if(!"".equals(beanName.trim())) {
- ioc.put(beanName,aClass.newInstance());
- }else{
- // 如果没有指定,就以类名首字母小写
- beanName = lowerFirst(aClass.getSimpleName());
- ioc.put(beanName,aClass.newInstance());
- }
-
-
- // service层往往是有接口的,面向接口开发,此时再以接口名为id,放入一份对象到ioc中,便于后期根据接口类型注入
- Class>[] interfaces = aClass.getInterfaces();
- for (int j = 0; j < interfaces.length; j++) {
- Class> anInterface = interfaces[j];
- // 以接口的全限定类名作为id放入
- ioc.put(anInterface.getName(),aClass.newInstance());
- }
- }else{
- continue;
- }
-
- }
- }catch (Exception e) {
- e.printStackTrace();
- }
-
-
-
-
-
-
- }
-
-
- // 首字母小写方法
- public String lowerFirst(String str) {
- char[] chars = str.toCharArray();
- if('A' <= chars[0] && chars[0] <= 'Z') {
- chars[0] += 32;
- }
- return String.valueOf(chars);
- }
-
-
-
-
- // 扫描类
- // scanPackage: com.lagou.demo package----> 磁盘上的文件夹(File) com/lagou/demo
- private void doScan(String scanPackage) {
- String scanPackagePath = Thread.currentThread().getContextClassLoader().getResource("").getPath() + scanPackage.replaceAll("\\.", "/");
- File pack = new File(scanPackagePath);
-
- File[] files = pack.listFiles();
-
- for(File file: files) {
- if(file.isDirectory()) { // 子package
- // 递归
- doScan(scanPackage + "." + file.getName()); // com.lagou.demo.controller
- }else if(file.getName().endsWith(".class")) {
- String className = scanPackage + "." + file.getName().replaceAll(".class", "");
- classNames.add(className);
- }
-
- }
-
-
- }
-
- // 加载配置文件
- private void doLoadConfig(String contextConfigLocation) {
-
- InputStream resourceAsStream = this.getClass().getClassLoader().getResourceAsStream(contextConfigLocation);
-
- try {
- properties.load(resourceAsStream);
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- }
-
-
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- doPost(req,resp);
- }
-
-
- @Override
- protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- // 处理请求:根据url,找到对应的Method方法,进行调用
- // 获取uri
-// String requestURI = req.getRequestURI();
-// Method method = handlerMapping.get(requestURI);// 获取到一个反射的方法
- // 反射调用,需要传入对象,需要传入参数,此处无法完成调用,没有把对象缓存起来,也没有参数!!!!改造initHandlerMapping();
-// method.invoke() //
-
-
- // 根据uri获取到能够处理当前请求的hanlder(从handlermapping中(list))
- Handler handler = getHandler(req);
-
- try {
- ensureSecurity(handler , req);
- } catch (SecurityException e) {
- resp.getWriter().write(e.getMsg());
- return;
- }
-
- if(handler == null) {
- resp.getWriter().write("404 not found");
- return;
- }
-
- // 参数绑定
- // 获取所有参数类型数组,这个数组的长度就是我们最后要传入的args数组的长度
- Class>[] parameterTypes = handler.getMethod().getParameterTypes();
-
-
- // 根据上述数组长度创建一个新的数组(参数数组,是要传入反射调用的)
- Object[] paraValues = new Object[parameterTypes.length];
-
- // 以下就是为了向参数数组中塞值,而且还得保证参数的顺序和方法中形参顺序一致
-
- Map parameterMap = req.getParameterMap();
-
- // 遍历request中所有参数 (填充除了request,response之外的参数)
- for(Map.Entry param: parameterMap.entrySet()) {
- // name=1&name=2 name [1,2]
- String value = StringUtils.join(param.getValue(), ","); // 如同 1,2
-
- // 如果参数和方法中的参数匹配上了,填充数据
- if(!handler.getParamIndexMapping().containsKey(param.getKey())) {continue;}
-
- // 方法形参确实有该参数,找到它的索引位置,对应的把参数值放入paraValues
- Integer index = handler.getParamIndexMapping().get(param.getKey());//name在第 2 个位置
-
- paraValues[index] = value; // 把前台传递过来的参数值填充到对应的位置去
-
- }
-
-
- int requestIndex = handler.getParamIndexMapping().get(HttpServletRequest.class.getSimpleName()); // 0
- paraValues[requestIndex] = req;
-
-
- int responseIndex = handler.getParamIndexMapping().get(HttpServletResponse.class.getSimpleName()); // 1
- paraValues[responseIndex] = resp;
-
-
-
-
- // 最终调用handler的method属性
- try {
- Object res = handler.getMethod().invoke(handler.getController(), paraValues);
- resp.getWriter().write(res.toString());
-
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- }
-
- }
-
- private boolean ensureSecurity(Handler handler, HttpServletRequest req) throws SecurityException{
- String[] usernames = req.getParameterValues("username");
- if (usernames!=null && usernames.length > 0 && handler.getAllowedUserSet().contains( usernames[0] )){
- return true;
- }else{
- throw new SecurityException(999 , "no ahth!");
- }
-
- }
-
- private Handler getHandler(HttpServletRequest req) {
- if(handlerMapping.isEmpty()){return null;}
-
- String url = req.getRequestURI();
-
- for(Handler handler: handlerMapping) {
- Matcher matcher = handler.getPattern().matcher(url);
- if(!matcher.matches()){continue;}
- return handler;
- }
-
- return null;
-
- }
-
-
-}
diff --git a/code/mvc/src/main/resources/springmvc.properties b/code/mvc/src/main/resources/springmvc.properties
deleted file mode 100644
index 28e2b4697da4d45c40b38bf90f9bfc6bbb05dfd9..0000000000000000000000000000000000000000
--- a/code/mvc/src/main/resources/springmvc.properties
+++ /dev/null
@@ -1 +0,0 @@
-scanPackage=com.lagou.demo
\ No newline at end of file
diff --git a/code/mvc/src/main/webapp/WEB-INF/web.xml b/code/mvc/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index b3de15423589bc64cd655b20ef49d2a5f038f774..0000000000000000000000000000000000000000
--- a/code/mvc/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
- Archetype Created Web Application
-
-
-
- lgoumvc
- com.lagou.edu.mvcframework.servlet.LgDispatcherServlet
-
- contextConfigLocation
- springmvc.properties
-
-
-
-
- lgoumvc
- /*
-
-
diff --git a/code/mvc/src/main/webapp/index.jsp b/code/mvc/src/main/webapp/index.jsp
deleted file mode 100644
index c38169bb958579c635a5c09ee2f379cc5956c0c2..0000000000000000000000000000000000000000
--- a/code/mvc/src/main/webapp/index.jsp
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-Hello World!
-
-
diff --git "a/\344\275\234\344\270\232\351\252\214\350\257\201\350\265\204\346\226\231/my\344\275\234\344\270\232\350\256\262\350\247\243.pdf" "b/\344\275\234\344\270\232\351\252\214\350\257\201\350\265\204\346\226\231/my\344\275\234\344\270\232\350\256\262\350\247\243.pdf"
deleted file mode 100644
index 548c0945a1de17e642ae45712b06337e8f8dc5a2..0000000000000000000000000000000000000000
Binary files "a/\344\275\234\344\270\232\351\252\214\350\257\201\350\265\204\346\226\231/my\344\275\234\344\270\232\350\256\262\350\247\243.pdf" and /dev/null differ
diff --git "a/\344\275\234\344\270\232\351\252\214\350\257\201\350\265\204\346\226\231/\344\275\234\344\270\232\350\256\262\350\247\243.pdf" "b/\344\275\234\344\270\232\351\252\214\350\257\201\350\265\204\346\226\231/\344\275\234\344\270\232\350\256\262\350\247\243.pdf"
new file mode 100644
index 0000000000000000000000000000000000000000..82ae8fe4a17506a1af1f18ef5485e291be29a224
Binary files /dev/null and "b/\344\275\234\344\270\232\351\252\214\350\257\201\350\265\204\346\226\231/\344\275\234\344\270\232\350\256\262\350\247\243.pdf" differ
diff --git "a/\345\220\254\350\257\276\347\254\224\350\256\260/1. \345\237\272\347\241\200\345\233\236\351\241\276.pdf" "b/\345\220\254\350\257\276\347\254\224\350\256\260/1. Spring boot \345\237\272\347\241\200\345\233\236\351\241\276.pdf"
similarity index 32%
rename from "\345\220\254\350\257\276\347\254\224\350\256\260/1. \345\237\272\347\241\200\345\233\236\351\241\276.pdf"
rename to "\345\220\254\350\257\276\347\254\224\350\256\260/1. Spring boot \345\237\272\347\241\200\345\233\236\351\241\276.pdf"
index cae6aee6da25894bec2ff3604537b579e2dd6a97..ba11cff6455e4745f0a061457e118d227ce49f8f 100644
Binary files "a/\345\220\254\350\257\276\347\254\224\350\256\260/1. \345\237\272\347\241\200\345\233\236\351\241\276.pdf" and "b/\345\220\254\350\257\276\347\254\224\350\256\260/1. Spring boot \345\237\272\347\241\200\345\233\236\351\241\276.pdf" differ
diff --git "a/\345\220\254\350\257\276\347\254\224\350\256\260/2. Spring boot \346\272\220\347\240\201\345\211\226\346\236\220.pdf" "b/\345\220\254\350\257\276\347\254\224\350\256\260/2. Spring boot \346\272\220\347\240\201\345\211\226\346\236\220.pdf"
new file mode 100644
index 0000000000000000000000000000000000000000..1dd8de39fc1d9fda8f2bb4c4bdca04e932ef1a3e
Binary files /dev/null and "b/\345\220\254\350\257\276\347\254\224\350\256\260/2. Spring boot \346\272\220\347\240\201\345\211\226\346\236\220.pdf" differ
diff --git "a/\345\220\254\350\257\276\347\254\224\350\256\260/2. \350\207\252\345\256\232\344\271\211MVC\346\241\206\346\236\266.pdf" "b/\345\220\254\350\257\276\347\254\224\350\256\260/2. \350\207\252\345\256\232\344\271\211MVC\346\241\206\346\236\266.pdf"
deleted file mode 100644
index 9b40052e58da190ea65367c9961304daa8828ea2..0000000000000000000000000000000000000000
Binary files "a/\345\220\254\350\257\276\347\254\224\350\256\260/2. \350\207\252\345\256\232\344\271\211MVC\346\241\206\346\236\266.pdf" and /dev/null differ
diff --git "a/\345\220\254\350\257\276\347\254\224\350\256\260/\347\233\264\346\222\255.pdf" "b/\345\220\254\350\257\276\347\254\224\350\256\260/\347\233\264\346\222\255.pdf"
new file mode 100644
index 0000000000000000000000000000000000000000..df0fe4f41993d7d880c7547591366c007c1b6fc5
Binary files /dev/null and "b/\345\220\254\350\257\276\347\254\224\350\256\260/\347\233\264\346\222\255.pdf" differ
diff --git "a/\345\220\254\350\257\276\347\254\224\350\256\260/\351\242\204\344\271\240.pdf" "b/\345\220\254\350\257\276\347\254\224\350\256\260/\351\242\204\344\271\240.pdf"
index 7075863b7c336bfa0753b1f796070bcf019a81a4..86ead192eb572b8a3ca6125f9e4224b4d6953d60 100644
Binary files "a/\345\220\254\350\257\276\347\254\224\350\256\260/\351\242\204\344\271\240.pdf" and "b/\345\220\254\350\257\276\347\254\224\350\256\260/\351\242\204\344\271\240.pdf" differ