好的建议建一个bug解决好的建议列表,这里多看控制台打印的错误提示信息,多学一点英语
今天想要通过传输base64字符串获取数据,结果出现了一个bug
2024-06-01 09:27:11.180 ERROR 18484 --- [nio-9090-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalArgumentException: Illegal base64 character 3a] with root cause java.lang.IllegalArgumentException: Illegal base64 character 3a
翻译
错误18484-【nio-9090-exec-1】o . a . c . c . c .【[.[/].【dispatcherServlet】:路径为【】的上下文中的servlet【dispatcher servlet】的Servlet.service()引发异常【请求处理失败;嵌套异常是Java . lang . illegalargumentexception:非法的base64字符3a】并带有根本原因 Java . lang . illegalargumentexception:非法的base64字符3a
在查阅了大佬资料后找到了答案,参考资料数据加解密时Base64异常:Illegal base64 character 3a-CSDN博客
原来是自己处理base64字符串的时候直接把base64字符串,给带上
这里经过传输的字符串要经过切割,这里的切割流程
<template> <div class="container"> <Area v-on:setImgSrc="setImgSrc"/> <textarea v-model="value"></textarea> </div> </template> <script> import Area from "@/views/until/BaseView"; import axios from "axios"; export default { components: { Area }, data: function() { return { value: '', } }, methods: { setImgSrc: function (value) { this.value = value; // console.log(this.value) var imgArr = []; var that = this; var str = ''; // var str1 = ''; str = that.value; imgArr = str.split(','); // 切割的部分 // str1 = imgArr[1]; // console.log(typeof str1); // console.log(typeof imgArr[1]); axios.post('http://localhost:9090/text/text-only',{ imgBase64: imgArr[1], imgType: 'png' }).then(function(res){ that.resdata = res.data; that.resdata.forEach((v)=>{ that.str = that.str + v.text }) console.log(that.str) }); // str = imgArr[1] // console.log(imgArr[1]) // 切割写法 // console.log(str); // axios.post('http://localhost:9090/text/text-only',{ // imgBase64: , // imgType: 'png' }).then(function(res){ // that.resdata = res.data; // that.resdata.forEach((v)=>{ // that.str = that.str + v.text // }) // console.log(that.str) // }) // } } } } </script> <style> textarea { display: block; height: 200px; max-width: 100%; min-width: 100%; padding: calc(0.75em - 1px); resize: vertical; box-shadow: inset 0 0.0625em 0.125em rgba(10, 10, 10, 0.05); width: 100%; background-color: #fff; border-color: #dbdbdb; border-radius: 4px; box-sizing: border-box; } </style>
最终呈现的效果