在使用富文本编辑器editor.md的过程中,发现前后端代码都没有问题,但是总是报错,不能上传成功,也没有进入后台上传图片部分的代码。
报错信息如下:
jquery.js:8510 POST http://localhost/uploadFile?guid=1557654068165 405
trigger @ jquery.js:8510
(anonymous) @ jquery.js:8549
each @ jquery.js:367
each @ jquery.js:202
trigger @ jquery.js:8548
(anonymous) @ image-dialog.js:176
dispatch @ jquery.js:5237
elemData.handle @ jquery.js:5044
VM366:1 Uncaught SyntaxError: Unexpected token W in JSON at position 0
at JSON.parse (<anonymous>)
at HTMLIFrameElement.uploadIframe.onload (image-dialog.js:161)
经过多次调试检验,发现是由于使用了csrf导致的,使用了csrf在前后端交互过程中必须带有一个token。
暂时的解决方法是关闭csrf…
在Security配置代码中添加关闭csrf的代码:
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/css/**", "/js/**", "/fonts/**", "/index", "/editor