jackyrong

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

  fckeditor是老外的东西,跟struts2配合时,要多注意些东西,下面小结之:

 

1 把fckeditor的目录(里面包含editor的)放到web-root下

 

2 记得把fckeditor.properties放到工程的src目录下,其中这个fckeditor.propertis中,

有几个注意的地方,比如:

# base directory for the user files relative to the context root
connector.userFilesPath = /uploadimage

这个userFilePath是用户上传文件的目录,这里是放在webroot目录下的uploadimage

 

# directory of the editor relative to the context root
fckeditor.basePath = /fckeditor

# default height of the editor
fckeditor.height = 200

# default toolbar set of the editor
fckeditor.toolbarSet = Default

 

这个fckeditor.basePath 是指定fckeditor目录叫什么名字,放在什么地方。默认是用default的显示工具条,应该足够了。

 

3 由于FCKEDITOR有中文问题,特别是上传附件时,因此要改写一下其中的一个servlet,

改写的是ConnectotrServlet.java,可以重新写一个,把原来的FCKEDITOR代码解开,

复制一份,再修改:

 

 String baseName = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());
     
     String extension = FilenameUtils.getExtension(filename);

     if (!ExtensionsHandler.isAllowed(resourceType, extension))
      ur = new UploadResponse(UploadResponse.SC_INVALID_EXTENSION);
     else {
      

      newFilename = baseName.concat(".").concat(extension);
      // construct an unique file name
      File pathToSave = new File(currentDir, newFilename);

即改成按日期时间来命名文件,同时在

web.xml中,进行如下修改:

<servlet>
  <servlet-name>Connector</servlet-name>
  <servlet-class>
   com.djs.common.ConnectorServlet
  </servlet-class>
  <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet-mapping>
  <servlet-name>Connector</servlet-name>
  <url-pattern>
   /fckeditor/editor/filemanager/connectors/*
  </url-pattern>
  </servlet-mapping>

 

4  最后注意要把几个包放到lib中去,比如:

 common-fileuplad.1.2.1,common-io-1.3.2(注意要用高版本的,否则在编辑器上传图片时会报错),还有fckeditor-for -java的包就可以了

 

posted on 2009-12-27 12:04  jackyrong的世界  阅读(883)  评论(0编辑  收藏  举报