Environment: RAD IDE, JSP, tinyMCE. I am tryin开发者_如何学Gog to build a rich text editor using tinyMCE and JSP. Steps:
- I downloaded the TinyMCE 3.4.3 package (comment -production usage) from http://tinymce.moxiecode.com/download/download.php
- unzipped the package and placed the "tinymce" folder under WebContent folder.
- Modified the jsp code with javascript code as mentioned
Code:
<head>
<script type="text/javascript" src="insertYourPath/tinymce/jscripts/tiny_mce/tiny_mce.js" ></script>
<script type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "simple" //(n.b. no trailing comma, this will be critical as you experiment later)
});
</script>
</head>
Issue: The JSP shows an error that tinyMCE is not resolvable and I don't see the editor being rendered. I added a check for tinymce.editors.length > 0
also and it also returned the same result.
Any suggestions why tinyMCE.init
doesn't work?
Your JavaScript URL is invalid.
<script type="text/javascript" src="insertYourPath/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
It says insertYourPath
which is clearly an example path. It seems that you did not take this into account and edited it accordingly.
When the JSP is located in webcontent root, just remove it:
<script type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
Or when you don't want to worry about relative URLs because your JSPs can be in any folder or being forwarded by a servlet according the MVC ideology, then include the context path dynamically:
<script type="text/javascript" src="${pageContext.request.contextPath}/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
This Helps well to get editor coming up with all the required fields. Its just need to turn off the jsp validator if do not want to see red with "tinyMCE.init". Thanks.
精彩评论