How to configure the FCKeditor online editor in the struts2 + hibernate Project

Source: Internet
Author: User

If you are not surprised when you are working on a project, more than 90% of the projects will certainly use an online editor. Therefore, it is necessary to integrate the editor in the project, here, I will only introduce how to configure the FCKeditor editor in the struts2 + hibernate project. I will not talk much about other xheditor and sina editor.

1. First of all, you have the FCKeditor editor. go online and download it. Then I put it in the dl_pro_admin directory (under the background folder)

2, need to import the corresponding jar package (fckeditor-java-core-2.4.jar), if not go to the official website or to download csdn and so on.

3. Create the file FCKeditor. properties under the SRC project. The content is

# FCKeditor setting
# File path directory uploaded by the user
Connector. userfilespath =/dl_pro_admin/useruploadfile
Connector. useractionimpl = net. FCKeditor. requestcycle. impl. useractionimpl

4. First, make sure that all operations involving action must be added. action, such as addnew. in the past, I did not add any action. action because struts2 will add it to you by default. action, but later with the editor, I found that I was wrong, it took a lot of effort, all the action operations are added. action.

5. After configuration, You need to modify the Web. xml file. I posted all my posts. Note that it is not/*, but *. Action *. jsp.

<? XML version = "1.0" encoding = "UTF-8"?>
<Web-app version = "2.5"
Xmlns = "http://java.sun.com/xml/ns/javaee"
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xsi: schemalocation = "http://java.sun.com/xml/ns/javaee
Http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd>
<Welcome-file-List>
<Welcome-File> test. jsp </welcome-File>
</Welcome-file-List>

<! -- FCKeditor configuration -->
<Servlet>
<Servlet-Name> connector </servlet-Name>
<Servlet-class> net. FCKeditor. connector. connectorservlet </servlet-class>
<Load-on-startup> 1 </load-on-startup>
</Servlet>
<Servlet-mapping>
<Servlet-Name> connector </servlet-Name>
<URL-pattern>/dl_pro_admin/FCKeditor/Editor/filemanager/connectors/* </url-pattern>
</Servlet-mapping>


<Filter>
<Filter-Name> struts2 </filter-Name>
<Filter-class> org. Apache. struts2.dispatcher. Ng. Filter. strutsprepareandexecutefilter </filter-class>
</Filter>
<Filter-mapping>
<Filter-Name> struts2 </filter-Name>
<URL-pattern> *. Action </url-pattern>
</Filter-mapping>

<Filter-mapping>
<Filter-Name> struts2 </filter-Name>
<URL-pattern> *. jsp </url-pattern>
</Filter-mapping>

</Web-app>

6. Now all the configurations are complete and you can see how to call them on the website background page.

7. Load the editor on the page, add the following code to the page header, pay attention to the path, and modify it.

<Link href = "<% = basepath %> dl_pro_admin/FCKeditor/_ samples/sample.css" rel = "stylesheet" type = "text/CSS"/>
<SCRIPT type = "text/JavaScript" src = "<% = basepath %> dl_pro_admin/FCKeditor. js"> </SCRIPT>
<SCRIPT type = "text/JavaScript">

// Initialize FCKeditor
Window. onload = function ()
{
VaR sbasepath = "<% = basepath %> dl_pro_admin/FCKeditor /";
VaR ofckeditor = new FCKeditor ('Pro _ news_content ');
Ofckeditor. width = "100% ";
Ofckeditor. Height = "300 ";
Ofckeditor. basepath = sbasepath;
Ofckeditor. replacetextarea ();
}
</SCRIPT>

The form is as follows:

<Form action = 'add. action' method = 'post'>

<Textarea name = "pro_news_content" rows = "10" Cols = "80">
</Textarea>

</Form>

In this case, the obtained pro_news_content is the same as the username in <input type = 'text' name = 'usernmae'/>.

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.