Struts2与fckeditor整合步骤
Struts2与fckeditor整合有一定难度,因为配置时他们的配置文件会有冲突,一步一步克服解决问题,你就成功了。
1,把下载的fckeditor文件夹直接拷贝到项目的WebRoot目录下。
2,把fckeditor与java相关的jar包加入到lib下。3,在src下新建一个servlet, ConnectorServlet.java覆盖fckeditor内置的servlet,在这里配置自己个性化的需求。
4,在web.xml中配置:
①
②把struts2的映射文件”/*”改为”*.action”:
例:
5,在项目的src下新建一个fckeditor.properties
里面加入内容:
https://www.wendangku.net/doc/701622132.html,erActionImpl=net.fckeditor.requestcycle.impl. UserActionImpl
6,在WebRoot下新建自己的fckeditor配置文件myconfig.js,在里面修改一些fckeditor的配置。
在项目表单中使用fckeditor
1,新建jsp页面
页面内引入fckeditor.js文件:例:
2,在页面内创建一个文本域,并用fckeditor替换该文本域。例:
v ar oFCKeditor=new FCKeditor('image');
o FCKeditor.BasePath="fckeditor/";
oFCKeditor.Config["CustomConfigurationsPath"]="/hotelManagement/m yconfig.js";
o FCKeditor.Height=200;
o FCKeditor.Width="50%";
o FCKeditor.ToolbarSet="myToolbarset";
o FCKeditor.ReplaceTextarea();
注意:此处var oFCKeditor=new FCKeditor('image');
创建FCKeditor时传入的参数既是textarea的name值。