创建Vue项目
- Vue环境搭建(node.js官网下载安装)
- 参考 该博客 2~5步
注意:在哪打开cmd,Vue项目就生成在哪
运行项目:npm run dev - 在vue中使用Bootstrap
最终采用下载Bootstrap文件的方式解决 - 保存用户登录状态
准备用vue-session,但是存在问题
后改用window.localstorage
创建Springboot项目
问题1:使用application.yml文件修改端口号不生效
yml格式对缩进有严格的要求(检查缩进)
错误
正确
问题2:java.lang.IllegalArgumentException: Invalid character found in method name [0x160x030x010x020x000x010x000x010xfc0x030x0330xe4E3$}0x180xef0xd20xf4T0xf70x850x090x0e0xe00xdb0xec0xd0f0xf5F/0xed0x930x1f0xd90x140x0e0xe0o0xdc]. HTTP method names must be tokens
可能是因为请求协议不对,需要统一成https或http请求。
问题3:后台接收到的数据显示为null
参考博客
引入 qs ,这个库是 axios 里面包含的,不需要再下载了。
import Qs from 'qs'
let data = {
"username": "cc",
"psd": "123456"
}
axios({
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
method: 'post',
url: '/api/lockServer/search',
data: Qs.stringify(data)
})
问题4:数据库报错
java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc, model, pic, province, title, totalprice, unitprice) values ('11', '河东�' at line 1
解决方案:DESC 在MYSQL中是关键字,字段名改名即可。
参考的博客
- 发送消息给后端:vue中使用axios发送请求