06 2021 档案
摘要:1.导入jdbc场景 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> jdbc中spring boot帮我
阅读全文
摘要:需要掌握的是继承接口WebMvcConfigurer这种方式,重写方法 以拦截器为例 @Configuration public class AdminConfig implements WebMvcConfigurer { //所有定制web功能的都是WebMvcConfigurer接口 publ
阅读全文
摘要:1.使用Servlet API @ServletComponentScan(basePackages = "com.sp") //可以自动将写的servlet扫描进去 配置扫描的包,在BootWeb01Application里面声明注解 @WebServlet(urlPatterns = "/my"
阅读全文
摘要:自定义404 5xx 页面,在文件夹下添加一个error的文件夹,里面添加对应的html 根据报错显示对应的html 自定义显示,在返回的信息中,浏览器返回的是json,此时包含了5个消息,时间、错误信息、堆栈、路径、状态码,只要是json信息都可以取到,通过thymeleaf里的th:text="
阅读全文
摘要:注意: 跳转html文件一定要放在同一个静态资源文件夹下,否则会出现各种报错 文件上传: 首先编写html的form表单提交,对于form表单的上传记得添加enctype,对于多文件上传,需要在input标签下添加multiple <!DOCTYPE html> <html lang="en"> <
阅读全文
摘要:Ctrl+F12 查看此类的方法,关系有哪些 必须继承这HandlerInterceptor 这个类 类中有三个方法 public class LoginIntercepter implements HandlerInterceptor { @Override public boolean preH
阅读全文
摘要:对于表单页面也说,F5相当于是再次重复提交表单信息到服务器,此时可以通过重定向来解决 @PostMapping("/login") public String main(String username,String password) { //登陆成功重定向到main.html ,防止表单重复提交
阅读全文
摘要:<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> 引入thyme leaf starter spr
阅读全文
摘要:@GetMapping("/send") public String getmessage(HttpServletRequest request) { request.setAttribute("msg","跳转"); //设置参数 request.setAttribute("code",123);
阅读全文
摘要:@PathVariable() 里面的参数可以是mapping里url的值,也可以是Map,Map必须是String Map(String,String),可以通过Map提取所有的路径变量 @GetMapping("/car/{id}/owner/{username}") public Map<St
阅读全文
摘要:再controller中编写同一个mapping的方法,但是对应的请求方式不同 package com.sp.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springfra
阅读全文
摘要:静态资源映射 请求进来,先取找Controller看能不能处理,不能处理的所有请求又都交给静态资源处理器,如果静态资源也找不到就会报404 package com.sp.Controller; import org.springframework.web.bind.annotation.Reques
阅读全文
摘要:properties 通过对pojo类进行@Component放入容器中, 之后通过@ConfigurationProperties(prefix = "person") 进行容器前缀绑定,前缀为person package spring.main.spring.Bean; import lombo
阅读全文
摘要:Lombok 简化JavaBean的开发,可以自动生成get set tostring方法,搜索和安装Lombok <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </dependen
阅读全文
摘要:在配置文件中application.properties中添加debug = true Negative matches 为不生效的 Negative matches: ActiveMQAutoConfiguration: Did not match: - @ConditionalOnClass d
阅读全文
摘要:以前的bean是通过xml文件导入,若还想通过xml可以使用@Importresource @ImportResource("classpath:文件名.xml") //导入spring的配置文件 @ConfigurationProperties 配置绑定 eg:mysql账户密码等等 contro
阅读全文
摘要:当满足某个条件的时候,才进行组件的注入 常见的如下: run.containsBean用于判断是否含有某个组件 System.out.println("++++++++++++++++++++++++++++++"); boolean tom = run.containsBean("tom"); S
阅读全文
摘要:@Component 代表一个组件 @Controller 代表是一个控制器 @Import({User.class}) //导入组件User类型的组件 @Import({User.class, DBAppender.class}) //导入组件User类型的组件,自动创建对应的无参构造器,创建出指
阅读全文
摘要:一、 SSM中bean的创建 在springboot中可以不写xml文件,改为用@Configuration的方式,告诉Spring boot这是一个配置类 ~~~ 配置文件 //通过注解方式@Bean来给容器中添加组件,类似于在配置文件.xml中配置<bean id="" class=""><pr
阅读全文
摘要:一、 在主程序中配置 @SpringBootApplication 相当于: //@SpringBootConfiguration @Configuration //主要由他组成 //@EnableAutoConfiguration @AutoConfigurationPackage @Import
阅读全文
摘要:from bs4 import BeautifulSoup import requests import time import os def get_photo(key): url = "https://desk.zol.com.cn/meinv/"+str(key)+".html" resp =
阅读全文
摘要:import requests from bs4 import BeautifulSoup import time url = "http://www.bizhi360.com/meinv/" resp = requests.get(url) resp.encoding = "utf-8" #pri
阅读全文
摘要:当网址有加密发送安全证书时可以使用verify=False,因为dytt利用的字符编码是gb2312,所以解码也要用gb2312 import requests domain = "https://dy.dytt8.net/index.htm" resp = requests.get(domain,
阅读全文
摘要:思路:通过requests获取html前端代码,通过re进行正则匹配,最后存储进csv中 首先导入requests、re、csv 之后再定义一个爬取的方法函数,通过观察url请求发现参数有start和filter,发现传递的参数中以25作为基准,所以在这里定义一个方法用来传递参数 def get_d
阅读全文
摘要:re解析(运行速度最快) . 匹配换行符以外的任意字符 \w 匹配字母或数字或下划线 \s 匹配任意的空白符 \d 匹配数字 \n 匹配一个换行符 \t 匹配一个制表符 ^ 匹配字符串的开始 $ 匹配字符串的结尾 \W 匹配非字母或数字或下划线 \D 匹配非数字 \S 匹配非空白符 a|b 匹配字符
阅读全文
摘要:通过爬取豆瓣的电影排行榜 import requests url = "https://movie.douban.com/j/chart/top_list" #params是get请求带参数 #data是post请求带参数 #重新进行封装参数 param = { "type":"24", "inte
阅读全文
摘要:不是python自带的,需要安装pip install requests import requests url = 'https://cn.bing.com/search?q=%E8%B1%86%E7%93%A3' #请求网页url一般是get请求,这里用requests的get方法 res =
阅读全文
摘要:from urllib.request import urlopen #打开网址,得到一个响应,利用python自带的urlopen url = "http://www.baidu.com" resp = urlopen(url) result = resp.read() from urllib.r
阅读全文

浙公网安备 33010602011771号