<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/froala-editor/2.7.6/js/froala_editor.pkgd.min.js"></script>
<script>
$(function() {
$('#edit').froalaEditor({
// Set the image upload URL.
imageUploadURL: 'upload_image',
imageUploadParams: {
id: 'my_editor'
}
})
});
</script>
<body>
<textarea id="edit" name="content"></textarea>
</body>
@PostMapping("/upload_image") public void process(HttpServletRequest request, HttpServletResponse response) throws Exception{
Map<Object, Object> responseData = null;
String linkName = "http://link";
responseData = new HashMap < Object, Object > ();
responseData.put("link", linkName);
// Send response data.
String jsonResponseData = new Gson().toJson(responseData);
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
response.setCharacterEncoding("UTF-8");
response.getWriter().write(jsonResponseData);
}
This doesn't return JSON to Froala editor. Please help.
HashMap, but just make yourprocessmethod return the object. (And if you need anything out of the request, like a parameter, just make it a method argument.) - chrylis -cautiouslyoptimistic-return responseData. Spring does all of the translation to JSON for you. - chrylis -cautiouslyoptimistic-