Notes for struts2 + FCKeditor

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.