Day58

Day58-SpringMVC01

1.导包

2.写配置

1)web.xml 写配置

2)框架自身要写的

<context:component-scan base-package ="com.sorrymaker"></context:component-scan>
3) 类上面要加 @Controller 告诉SpringMVC是一个处理器。

 

@PathVariable("")--->>获取路径变量

 

 

今日小知识

HttpServlet容器响应Web客户请求流程如下:

1)Web客户向Servlet容器发出Http请求;

2)Servlet容器解析Web客户的Http请求;

3)Servlet容器创建一个HttpRequest对象,在这个对象中封装Http请求信息;

4)Servlet容器创建一个HttpResponse对象;

5)Servlet容器调用HttpServlet的service方法,这个方法中会根据request的Method来判断具体是执行doGet还是doPost,把HttpRequest和HttpResponse对象作为service方法的参数传给HttpServlet对象;

6)HttpServlet调用HttpRequest的有关方法,获取HTTP请求信息;

7)HttpServlet调用HttpResponse的有关方法,生成响应数据;

8)Servlet容器把HttpServlet的响应结果传给Web客户。

 


高版本tomcat可能会有405的问题

解决方案:将错误封装到isErrorPage里, 即 是 --> isErrorPage = "True"

 


String a = "a";

String b = "a";

这样定义的a和b指向的是字符串常量区变量,地址是一样的,即用equals为true,用==也为true。

但是

String a =new String( "a");

String b = new String( "a");

这样是定义了两个堆内存对象,只能equals,不能==

posted @ 2021-06-14 13:15  独眼龙  阅读(49)  评论(0)    收藏  举报