这是我的初始化编辑器
DecoupledEditor
.create( document.querySelector( '#webDetails' ),{
language: 'zh-cn',
image: {
toolbar: [ 'imageTextAlternative' ],
styles: [ 'full', 'side' ]
},
ckfinder: {
uploadUrl: '<%=WEBPATH%>/loadImage'// 这个就是我上次的图片路径,我也不知道是不是这样配,但是我就是这样搞得,在后台可以接受到。
}
} )
.then( editor => {
const toolbarContainer = document.querySelector( '#toolbar-webDetails' );
toolbarContainer.appendChild( editor.ui.view.toolbar.element );
} )
@PostMapping("loadImage")
@ResponseBody
public String updateMaterial(@RequestParam("upload") MultipartFile file, HttpServletRequest request){
String trueFileName = null;
String realPath = null;
try {
realPath = request.getSession().getServletContext().getRealPath("/upload");
System.out.println(realPath);
trueFileName = uploadImg(realPath, file);
} catch (IllegalStateException | IOException e) {
e.printStackTrace();
}
return "{\"default\":\"" + realPath + File.separator + trueFileName + "\"}";
}
对我这边可以接受到,按道理 他上传后应该是返回的就是 ,上传结束后的图片地址,但是,应该有个格式吧,我看了官方的api 看不明白,菜鸟,找不到重点,随后我就在官方示例上 用了图片上传,看了返回的格式,首先是{"这是数字随机的":"";"default":"图片地址"}所以我返回的是 就上面的格式 default:图片地址了,这样但是失败了,不知道应该怎么办,求大神指教指教