文章分类 - web项目知识点
JSON.toJSONString 对象日期时间变成了时间戳的问题
摘要:String s=JSON.toJSONString(obj); 改为 String s=JSON.toJSONStringWithDateFormat(obj,"yyyy-MM-dd HH:mm:ss");
阅读全文
yaml 配置List数组对象并映射
摘要:1,User实体类 @Data public class User { private Integer id; private String name; private Integer age; } 2,yaml配置 com: company: list: - id: 1 name: tom age
阅读全文
字符编码转换
摘要:因为tomcat容器默认采用iso-8859-1的编码方式,导致中文乱码。需要将字符集改成utf-8的编码方式。 String name=request.getParameter("name"); String nameStr=new String(name.getBytes("ISO-8859-1
阅读全文
SpringBoot 使用RestTemplate调用第三方接口
摘要:HTTPClient 在RestTemplate出现之前,一般都是通过HTTPClient进行访问第三方接口。但是过程比较复杂。 public String httpClientTest() throws IOException { //1,创建httpClient CloseableHttpCli
阅读全文
requestMapping 请求参数
摘要:1,value,method value:指定请求的实际地址,指定的地址可以是URI Template模式。 method:指定请求的method类型,GET、POST、PUT、DELETE等。 2,consumes,produces consumes:指定处理请求的提交内容类型(content-t
阅读全文
mybatis 传入Integer类型的参数,当值为0时,查询的结果有误
摘要:mybatis 传入Integer类型的参数,当值为0时,查询的结果有误。 <if test=" isDelete != null and isDelete != '' "> and is_delete=#{isDelete} </if> 通过将sql打印出来,发现这个条件没有生效。 总结:myba
阅读全文
idea报找不到包,但包存在
摘要:确认包存在,但找不到包。很可能是缓存问题。 1,点击菜单栏File,Invalidate caches/Restart。 2,点击Invalidate and Restart继续。 3,等待idea重启,然后点击菜单栏Build,Build Project。
阅读全文
解决:Could not write JSON: No serializer found for class *** and no properties错误
摘要:场景:使用RestController或者Controller注解将查询的实体转换成json字符串时报错。 原因:需要转换的对应实体类的属性缺少:getter和setter方法,导致将实体类转换的json格式类无法读取对应的属性从而报错。 解决方法:在需要转换的实体类中给属性加上getter和set
阅读全文
idea debug模式提示 Method breakpoints may dramatically slow down debugging问题
摘要:点击图中按钮或者快捷键(ctrl+shift+f8)出现下图
阅读全文
idea 通过访问路径快速定位到对应的Controller
摘要:解决方法:idea安装RestfulToolkit插件。 file >settings >plugins >RestfulToolkit 使用方式: windows: Ctrl+Alt+N MAC:option+command+N
阅读全文
postman测试文件上传
摘要:后台代码 @PostMapping("/upload") public void upload(@RequestBody MultipartFile file){ //处理代码 } postman测试 注意:上传文件时点击下拉框时,只有光标不在文本框中时下拉框才会显示file出来。 测试的过程中,报
阅读全文
iframe 父页面传值给子页面
摘要:父页面 <body> 父级:A页面<br/><br/> <button id="children_button">传值给子元素 </button> <iframe src="XXX" width="500px" height="200px" id="iframe"></iframe> <script
阅读全文
后台date类型转换为json对象给前台,返回的是long类型的时间戳
摘要:pojo(实体类)对应的字段(日期)类型为Date类型,用jackson的注解@JsonFormat解决。 1,引用jackson 依赖(springboot自带jackson依赖) <dependency> <groupId>org.codehaus.jackson</groupId> <arti
阅读全文
连接Mysql报错CLIENT_PLUGIN_AUTH is required
摘要:连接Mysql时报错CLIENT_PLUGIN_AUTH is required pom中引用的mysql的依赖的版本(当没有指定版本时,默认是最新版本)高于实际连接的数据库的版本,需降低mysql的依赖的版本。另外,也要注意驱动类名的写法,不同版本的驱动类名可能不同。
阅读全文
Idea闪退报错There is not enough memory to perform the requested operation
摘要:Idea 闪退报错,There is not enough memory to perform the requested operation。 解决方法 在Idea的菜单中单击Help,然后点击Edit Custom VM Options选项。 弹出一个文件对话框 对其中的数据进行修改 重启Ide
阅读全文
Spring 简单定时任务
摘要:spring框架 1,定时任务 @Component public class HelloTask { @Scheduled(cron = "0/5 * * * * *") public void sayHello(){ String helloStr="hello "; System.out.pr
阅读全文
Springboot添加拦截器后或者页面跳转后静态资源访问失败问题
摘要:SpringBoot版本问题 SpringBoot2.X不再自动放行静态资源,添加拦截器后需要在mvc配置中exclude静态资源路径,即在excludePathPatterns()方法中添加"/static/**"参数。 @Override public void addInterceptors(
阅读全文
SpringBoot集成JPA返回json报错
摘要:错误提示:com.fasterxml.jackson.databind.exc.InvalidDefinitionException 主要在实体类上添加 如下注解就可以了。 @JsonIgnoreProperties(value = { "hibernateLazyInitializer", "ha
阅读全文
WebMvcConfigurationSupport 静态资源访问不了
摘要:WebMvcConfigurationSupport是Spring Boot2.0以后用来替代WebMvcConfigurerAdapter,但是如果直接使用WebMvcConfigurationSupport替换掉WebMvcConfigurerAdapter会出现各种问题。 原因就是使用WebM
阅读全文
SpringBoot 报错 IllegalStateException
摘要:java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with
阅读全文