
Springboot/java web
java
st紫月
这个人很懒,只想把你留下
展开
-
用React+Springboot+MySQL实现一个简单的登录功能
在entity包下创建一个user类,对应数据库中的user表。在mapper包下新建UserRepository接口。在启动类上加入代码扫描数据表的接口。原创 2023-04-21 23:31:25 · 761 阅读 · 0 评论 -
Springboot允许跨域
【代码】Springboot允许跨域。原创 2023-04-21 02:03:19 · 145 阅读 · 0 评论 -
Springboot项目目录介绍
Springboot项目目录介绍原创 2023-04-21 00:43:58 · 3426 阅读 · 0 评论 -
Tomcat的安装过程
下载地址:https://tomcat.apache.org/download-80.cgi左边的8.9.10是版本号,右边的zip是压缩包选择一个之后下载,解压到D盘的一个文件夹配置环境变量系统变量添加变量:变量名:CATALINA_HOME变量值:D:\Tomcat\apache-tomcat-8.5.72\bin(就是你刚刚解压的那个文件夹路径,这里不需要bin)在path中添加%CATALINA_HOME%\lib环境变量配置完成找到tomcat目录下的startup.bat文原创 2021-10-19 21:22:07 · 157 阅读 · 0 评论 -
Springboot应用的打包和部署(Jar、War)
传统的Web应用进行打包部署时,通常会打成War包的形式,然后将War包部署到Tomcat等服务器中,而Springboot应用使用的是嵌入式Servlet容器,也就是说Springboot应用默认是以Jar包形式进行打包部署的。Jar包方式打包部署:1.添加Maven打包插件: <build> <plugins> <plugin> <groupId>org.springfra原创 2022-04-16 16:33:54 · 5956 阅读 · 1 评论 -
Springboot实现文件的上传以及下载
编写test.html模板:<!DOCTYPE html><html lang="zh" xmlns="http://www.thymeleaf.org"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compat原创 2022-04-15 21:19:49 · 1558 阅读 · 0 评论 -
Springboot Lombok的使用
Lombok,一个Java类库,提供了一组注解,简化POJO实体类开发依赖:<dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <scope>provided</scope> </dependency>使用方原创 2022-04-08 20:07:59 · 428 阅读 · 0 评论 -
SpringBoot整合MVC和拦截器Interceptor
使用Springboot整合MVC进行web开发,实现简单的页面跳转功能@Configurationpublic class MyMVCConfig implements WebMvcConfigurer { @Override public void addViewControllers(ViewControllerRegistry registry){ //请求toLoginPage映射路径或者login.html都会自动渲染login.html模板,setView原创 2022-04-08 16:59:57 · 651 阅读 · 0 评论 -
Springboot接收GET和POST请求参数
接收GET请求参数:@RestControllerpublic class test { //参数可以为空 @GetMapping("/test") public String hello(@RequestParam(name = "name", required = false) String name) { return "获取到的name是:" + name; }}没有参数时为nullController 还可以直接使用 map 来接收所原创 2022-04-07 22:13:47 · 2825 阅读 · 0 评论 -
java springboot+thymeleaf 实现图片上传并展示到页面当中
先在配置文件当中编写文件上传的路径:file.upload.path=D://program/Springbootstudentsystem/src/main/resources/static/file.upload.path.relative=/static/**创建一个MyWebAppConfigurer java文件实现WebMvcConfigurer接口, 配置资源映射路径package com.example.springbootstudentsystem;import org.sp原创 2022-04-07 21:38:23 · 1162 阅读 · 0 评论 -
Springboot 整合MyBaties、Druid、JPA,并且将查询到的数据响应到前台
Springboot常用的依赖<!-- Spring Boot提供的配置处理器依赖,代码提示 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <op原创 2022-04-06 21:32:21 · 951 阅读 · 0 评论 -
java Springboot解决跨域问题 No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.
问题:在Controller类上加一个@CrossOrigin注解package com.example.springbootstudentsystem;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.*;@CrossOrigin@Controllerpublic class test { @ResponseBody @Post原创 2022-04-06 19:15:37 · 604 阅读 · 0 评论 -
Springboot访问静态资源文件的html以及图片
Springboot的静态资源文件夹是项目的resource目录下的static文件夹,并且Springboot会默认开放静态资源文件,不需要做什么设置想要访问静态资源文件需要先导入依赖<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId></dependency&g原创 2022-04-06 12:33:44 · 2495 阅读 · 0 评论 -
SpringBoot: Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datas
Spring Boot项目中含有Mybatis,打Jar包运行之后,报如下错误.问题原因: Mybatis没有找到合适的加载类,其实是大部分spring - datasource - url没有加载成功,分析原因如下所示.DataSourceAutoConfiguration会自动加载.没有配置spring - datasource - url 属性.spring - datasource - url 配置的地址格式有问题.配置 spring - datasource - url的文件没有加载.原创 2022-04-06 12:10:12 · 213 阅读 · 0 评论 -
SpringBoot 中@Controller/@RestController/@RequestMap注解的使用
1.@Controller必须配合模版来使用在resources目录的templates目录下添加一个hello.html文件代码:@Controllerpublic class HelloController { @RequestMapping(value="/hello",method= RequestMethod.GET) public String sayHello(){ return "hello"; }}@Controller的作用就是当访原创 2022-04-02 21:15:23 · 1959 阅读 · 0 评论 -
Springboot注解@ConfigurationProperties、@Value、@PropertySource、@ImportResource、@Configuration的使用方法
1.@ConfigurationProperties与@Value在application.properties当中写一个person的属性person.name=tomperson.age=16创建一个person类package com.example.springboot;import org.springframework.boot.context.properties.ConfigurationProperties;import org.springframework.stere原创 2022-03-11 20:09:33 · 348 阅读 · 0 评论 -
javaweb Servlet和jsp的基本使用方法
原创 2022-01-09 00:27:02 · 333 阅读 · 0 评论 -
JAVA JDBC和数据库连接池Druid的使用
JDBC:是官方定义大的一套操作所有关系型数据库的规则,即接口MySQL驱动jar包的下载方式:地址:https://dev.mysql.com/downloads/选择platform independent下载JDBC使用步骤:1.导入驱动jar包:复制到项目下的libs目录下,并且Add As Library2.注册驱动3.获取数据库连接对象Connection4.定义sql5.获取执行sql语句的对象statement6.执行sql,接收返回结果7.处理结果8.释放资源原创 2022-01-02 00:30:37 · 936 阅读 · 0 评论 -
Springboot配置文件
配置文件的分类Springboot是基于约定的,所以很多配置项都有默认值,但如果想使用自己的配置替换默认配置的话,可以使用application.properties(在resources目录下)或者application.yml(yaml是一样的)进行配置properties:server.port=8080(改变默认端口号)yml:server:port:8080YAML基本语法:数据前面都需要有一个空格1.大小写敏感2.数据值前边必须有空格,作为分隔符3.使用缩进表示层级关系4.原创 2021-10-23 02:40:12 · 505 阅读 · 0 评论 -
使用IDEA快速搭建Springboot项目
点击next,填好坐标之后再点击下一步,选择spring web,会自动生成配置项项目构建完成之后,截图如下在java当中新建一个hello.java输入以下代码:package com.example.demo;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;@RestControll..原创 2021-10-23 01:04:05 · 135 阅读 · 0 评论