您的位置:首页 > 编程语言 > Java开发

fckeditor2.6.6 java上传图片到绝对路径的配置

2014-01-12 12:47 447 查看
改绝对路径不需要修改源码。增加一些简单的配置就可以了。可以回显。另外要设置tomcat的server.xml,加一个硬盘映射。

fckeditor 2.6.6

我的是maven工程。

1:拷贝fckeditor文件夹到webapp/js下面

2:修改fckeditor/fckeditor.js里面的FCKeditor.BasePath = '/js/fckeditor/' ;

3:web.xml里面加入

<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>
/js/fckeditor/editor/filemanager/connectors/*
</url-pattern>
</servlet-mapping>


4:src/main/resources下面新建fckeditor.properties,写入

connector.userActionImpl=net.fckeditor.requestcycle.impl.EnabledUserAction

#connector.impl = net.fckeditor.connector.impl.LocalConnector
#connector.userPathBuilderImpl = com.hb.FilePathBuilder

#################################################################
#connector.impl=com.hb.ContextConnector
#connector.userPathBuilderImpl = com.hb.ContextPathBuilder

connector.userFilesAbsolutePath = E://image
connector.userFilesPath = http://localhost:9080/image 
connector.userPathBuilderImpl = net.fckeditor.requestcycle.impl.ServerRootPathBuilder
connector.impl = net.fckeditor.connector.impl.LocalConnector


5:加入依赖。pom里面加入

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>net.fckeditor</groupId>
<artifactId>java-core</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.devlib.schmidt</groupId>
<artifactId>imageinfo</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.5.8</version>
</dependency>


6:server.xml配置context,加入

<Context path="/image" docBase="E:\image" reloadable="true" debug="0"/>

7:jsp文件

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.fckeditor.net" prefix="FCK"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>FckEditor测试</title>
</head>
<body style="text-align: center;">
<div style="text-align: center;width: 600pt">
<h2>FckEditor测试</h2>
<hr>
<form action="ShowData.jsp" method="post">
<FCK:editor basePath="/js/fckeditor/" instanceName="test" height="400pt">
<jsp:attribute name="value">www.sunchis.com</jsp:attribute>
</FCK:editor>
<input type="submit" value="提交"/>
<input type="reset" value="重置"/>
</form>
</div>
</body>
</html>


如果设置了fckeditor的基本路径,比如这里房子js下面,要修改的地方有jsp里面的basePath、web.xml、fckeditor.xml

如果直接放在webapp下面,这些文件都不需要修改

You are not authorized to browse/list files and/or folders

我开始没有使用pom配置jar包,后来fckeditor.properties里面类名后面多了空格,报出这个错误。实际上是因为fck默认不提供上传图片的权限,必须声明connector.userActionImpl=net.fckeditor.requestcycle.impl.EnabledUserAction

而web.xml配置fck路径错误的话,会报出The server didn't reply with a proper XML data. Please check your configuration.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: