FCKeditor is a foreigner. When working with struts2, pay more attention to the following:
1. Put the FCKeditor directory (which contains the editor) under Web-root.
2. Put FCKeditor. properties in the src directory of the project, where FCKeditor. propertis is located,
There are several notes, such:
# Base directory for the user files relative to the context Root
Connector. userfilespath =/uploadimage
This userfilepath is the directory where the user uploads files. This is the uploadimage stored in the webroot directory.
# 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
This FCKeditor. basepath specifies the name and place of the FCKeditor directory. The default display toolbar is used by default. It should be enough.
3 because FCKeditor has a Chinese problem, especially when uploading attachments, You need to rewrite one of the servlets,
The rewrite is connectotrservlet. java. You can re-write the original FCKeditor.CodeUnlock,
Copy one copy before modification:
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 );
That is, the file is named by date and time.
In web. XML, make the following changes:
<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. put several packages in Lib, for example:
Common-fileuplad.1.2.1, common-io-1.3.2 (Be sure to use a later version, or an error will be reported when the editor uploads an image), and FCKeditor-for-Java package is enough