我希望使用数据来初始化tinymce文本区域。我该如何从控制器获取数据到tinymce文本区域?
我设法使用ajax post方法从网页中检索内容到控制器。
我的控制器
@RequestMapping(value = "")
public String incidentNotesDetail(@PathParam("id") Long id, Model model, Principal principal) {
return "incidentNotes";
}
@RequestMapping(value = "/update", method = RequestMethod.POST)
public String incidentNotesDetailPost(@RequestParam("content") String content, HttpServletRequest request) {
System.out.println(content);
return "/incidentNotes";
}
我的HTML
<body>
<h1>Incident Notes</h1>
<form action="@{/incidentNotes/update}" method="post">
<textarea id="myTextarea">
<table border="0" cellspacing="0" cellpadding="0" width="712">
<tr >
<td id="notesSn" width="25" style="border:groove" ><p align="center"><strong>S/N</strong></p></td>
<td width="255" style="border:groove"><p align="center"><strong>Title</strong></p></td>
<td width="101" style="border:groove"><p align="center"><strong>Timestamp</strong></p></td>
<td width="461" style="border:groove"><p align="center"><strong>Description</strong></p></td>
</tr>
</table>
</textarea>
</form>
<script>
tinymce
.init({
selector : '#myTextarea',
skin : "oxide-dark",
height : 800,
plugins : [
"advlist autolink lists link charmap print preview anchor",
"searchreplace visualblocks",
"insertdatetime media table contextmenu paste save" ],
toolbar : " save | print | insertfile undo redo |styleselect | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent",
init_instance_callback : function(editor) {
tinymce.get('myTextarea').setContent("Hello");
},
save_onsavecallback : function() {
var content = tinymce.activeEditor.getContent();
console.log(content);
$
.ajax({
type : 'post',
cache : false,
url : "/incidentNotes/update",
data : {
"content" : content
},
success : function() {
tinymce.activeEditor.windowManager
.alert("This page has been successfully saved");
}
});
}
});
</script>
我希望tinymce文本区域显示我从控制器发送的数据。