Spring

axios发post请求,后端接收不到参数的问题

与世无争的帅哥 提交于 2021-02-17 02:04:11
axios会帮我们自动转换请求数据和响应数据 以及 自动转换JSON数据,我们的请求头转换成 Content-Type变成了application/json;charset=utf-8,然后因为我们的参数是JSON对象, axios帮我们做了一个stringfy的处理,axios在发送post请求时,默认直接把json放在请求体中提交到后端的。 但是后台可能使用的时java spring mvc,并且使用的注解是@requestParam,这个只能从请求的地址中取出参数,也就是只能从请求链接中截取出参数。要求的Content-Type是'application/x-www-form-urlencoded',所以后端就接收不到参数; 解决办法: 1 使用URLSearchParams传递参数 let params=new URLSearchParams(); params.append('username','admin'); params.append('psd','222222'); axios({ method:'post',url:'/api/test/aa',data:params }); URLSearchParams不支持所有的浏览器 2 把参数修改为query参数 直接修改axios的header content-type,axios.defaults.headers

SpringBoot入门(二)——起步依赖

泄露秘密 提交于 2021-02-16 23:14:24
本文来自 网易云社区 在前一篇我们通过简单几步操作就生成了一个可以直接运行的Web程序,这是因为SpringBoot代替我们做了许多工作,概括来讲可以分为起步依赖和自动配置。这一篇先来看看起步依赖。 项目构建过程解析 前面提到,Spring Boot构建出来的也是一个Maven项目,可以看下自动生成的pom.xml文件: <?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>top.godtm</groupId> <artifactId>blog-demo</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>blog-demo</name> <description

Mybatis异常:java.lang.ClassNotFoundException: org.mybatis.spring.SqlSessionFactoryBean

徘徊边缘 提交于 2021-02-16 23:14:01
Mybatis异常:java.lang.ClassNotFoundException: org.mybatis.spring.SqlSessionFactoryBean 参考文章: (1)Mybatis异常:java.lang.ClassNotFoundException: org.mybatis.spring.SqlSessionFactoryBean (2)https://www.cnblogs.com/haimishasha/p/6188266.html 备忘一下。 来源: oschina 链接: https://my.oschina.net/u/3797416/blog/4953242

SpringBoot入门(二)——起步依赖

可紊 提交于 2021-02-16 21:50:09
本文来自 网易云社区 在前一篇我们通过简单几步操作就生成了一个可以直接运行的Web程序,这是因为SpringBoot代替我们做了许多工作,概括来讲可以分为起步依赖和自动配置。这一篇先来看看起步依赖。 项目构建过程解析 前面提到,Spring Boot构建出来的也是一个Maven项目,可以看下自动生成的pom.xml文件: <?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>top.godtm</groupId> <artifactId>blog-demo</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>blog-demo</name> <description

How to modify or custom sessionId in spring session project?

a 夏天 提交于 2021-02-16 20:57:44
问题 My project use Spring Boot and Spring Session,now i want to modify or custom sessionId before session data persistence in redis,How should I do? thanks! 回答1: Maybe you need to go through the docs Spring Session works well with spring boot Docs :http://docs.spring.io/spring-session/docs/current/reference/html5/ It will tell you that coupling the custom implementation with @EnableSpringHttpSession support allow to easily reuse existing Spring Session configuration facilities and infrastructure.

How to modify or custom sessionId in spring session project?

筅森魡賤 提交于 2021-02-16 20:53:09
问题 My project use Spring Boot and Spring Session,now i want to modify or custom sessionId before session data persistence in redis,How should I do? thanks! 回答1: Maybe you need to go through the docs Spring Session works well with spring boot Docs :http://docs.spring.io/spring-session/docs/current/reference/html5/ It will tell you that coupling the custom implementation with @EnableSpringHttpSession support allow to easily reuse existing Spring Session configuration facilities and infrastructure.

Stackoverflow error when saving an Object's toString value - Java/Hibernate/Spring

ぐ巨炮叔叔 提交于 2021-02-16 20:07:37
问题 I have the following sample entities: Institution @Data @Entity @NoArgsConstructor @EntityListeners(InstitutionAuditListener.class) public class Institution extends Auditable<String> { @OneToMany(mappedBy = "institution", cascade = CascadeType.ALL) @JsonManagedReference private List<RegisteredProgram> registeredPrograms; private String name; } RegisteredProgram @Data @NoArgsConstructor @Entity @EntityListeners(RegisteredProgramAuditListener.class) public class RegisteredProgram extends

Stackoverflow error when saving an Object's toString value - Java/Hibernate/Spring

谁说胖子不能爱 提交于 2021-02-16 20:07:17
问题 I have the following sample entities: Institution @Data @Entity @NoArgsConstructor @EntityListeners(InstitutionAuditListener.class) public class Institution extends Auditable<String> { @OneToMany(mappedBy = "institution", cascade = CascadeType.ALL) @JsonManagedReference private List<RegisteredProgram> registeredPrograms; private String name; } RegisteredProgram @Data @NoArgsConstructor @Entity @EntityListeners(RegisteredProgramAuditListener.class) public class RegisteredProgram extends

IDEA 公司推出新字体,极度舒适~

狂风中的少年 提交于 2021-02-16 19:57:16
Java技术栈 www.javastack.cn 优秀的Java技术公众号 这几天炒得沸沸扬扬的 Intellij IDEA 公司 JetBrains 推出了一种新字体: JetBrains Mono ,据说它是专为开发人员设计的,下面栈长带大家 一起 来吃个瓜。 JetBrains Mono 官方地址: https://www.jetbrains.com/lp/mono/ 栈长特地去了下 JetBrains Mono 官网,看起来还是挺舒适的: 如果你说,没什么舒适不舒适的,差不多,你再来看下 JetBrains Mono 和 Consolas 这两种字体的比较,应该明清晰了: 可以点击放大开 并且,从 2019.3 版本开始,JetBrains Mono 字体将随 JetBrains 系列 IDEs 一起提供。 使用方式: Preferences/Settings → Editor → Font, 然后选择 JetBrains Mono 字体。 当然,你也可以在老版本的 JetBrains 系列 IDEs 或者其他 IDE 开发工具中使用它 。 安装方式: https://www.jetbrains.com/lp/mono/#how-to-install 有兴趣的、爱折腾的朋友们也可以尝试下哦,生活和工作这么 boring 了,总要来点新花样不是。 END 学习资料:

Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError: Implementing class

穿精又带淫゛_ 提交于 2021-02-16 16:31:42
问题 error message: SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [config/spring/Hibernate-ctx.xml]: Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError: Implementing class at org.springframework.beans.factory.support