ckeditor with spring mvc not working

笑着哭i 提交于 2019-12-11 02:29:56

问题


I'm trying to integrate ckeditor with a spring mvc project and it does not seem to be working. As far as I can tell I'm following the documentation but something is wrong. The only output I get is a textarea with no toolbar or anything resembling ckeditor. This stays the same if I specify the "Full' toolbar. It appears as if ckeditor is not being found, but why?

Note: in my servlet-context.xml I have tried both

<resources mapping="/resources/**" location="/resources/" />

and

<resources location="/, classpath:/META-INF/web-resources/" mapping="/resources/**"/>

and still not found.

1) I have ckeditor 3.6.6 in Eclipse under the webapp directory. I copied all the files from the download.

2) My jsp has the following:

 <head>
    <script type="text/javascript" src="/ckeditor/ckeditor.js"></script>
    <script type="text/javascript" src="/ckeditor/adapters/jquery.js"></script>
    <title>Home</title>
 </head>

note: I've also tried referring to the src as src="/resources/ckeditor/..." but still no go.

<textarea id="editor1" name="editor1">&lt;p&gt;Initial value.&lt;/p&gt;</textarea>
<br>


 <script type="text/javascript">
CKEDITOR.replace( 'editor1',
    {
        toolbar : 'Basic',
        uiColor : '#9AB8F3'
    });
   </script>

回答1:


Might I suggest that you check your reference paths.

Your current path says that the ckeditor.js file should be located at http://example.com/ckeditor/ckeditor.js but I'm assuming that it's within a resources folder.

Try This:

<script type="text/javascript" src="/resources/ckeditor/ckeditor.js"></script>

I've posted another answer on how referencing resources should work. This should help you figure out why it's 404ing
How to properly reference local resources in HTML?

Alternatively, you can try the CDN hosted file.
however: there's no guarantee that jsdelivr will be online long term

<head>
   <script type="text/javascript" src="//cdn.jsdelivr.net/ckeditor/4.0.1/ckeditor.js"></script>
</head>

Also note, there are more plugins and such in the cdn
http://www.jsdelivr.com/#!ckeditor



来源:https://stackoverflow.com/questions/14486584/ckeditor-with-spring-mvc-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!