如何使用Java更改CKFinder 2.2中的文件上载URL

时间:2012-04-02 01:14:39

标签: java spring ckeditor ckfinder

我正在使用CKFinder-2.2和CKEditor-3.5.X一直很好,直到我尝试上传图像/文件并将其发送到图像。我尝试将文件发送到服务器No mapping found for HTTP request with URI [/my-project/ckfinder/core/connector/java/connector.java] in DispatcherServlet with name 'appServlet'时出现以下错误。我正在将Spring MVC 3用于此Web应用程序。

使用上传按钮的浏览服务器按钮可以正常工作,因为我在<url-pattern>的{​​{1}}中进行了必要的更改以使其正常工作,但我无法使用将其发送到服务器按钮将文件发送到服务器。

enter image description here

我认为错误是由web.xml中的以下行引起的:

CKFinderSetupCKEditor.java

我尝试了private static final String CKFINDER_UPLOAD_URL = "/ckfinder/core/connector/java/connector.java?command=QuickUpload&type="; private static final String CKFINDER_PAGE = "/ckfinder.html"; 的{​​{1}}属性以及下面提到的属性,但这也没有帮助。

config

有人可以帮我理解我在这里做错了什么以及如何完成它?它只是我要上传到我的服务器的文件。这应该不会太难。

1 个答案:

答案 0 :(得分:1)

如果有人遇到同样的问题,添加以下内容可以帮助我:

<强>的web.xml

<servlet>
    <servlet-name>ConnectorServlet</servlet-name>
    <servlet-class>com.ckfinder.connector.ConnectorServlet</servlet-class>
    <init-param>
        <param-name>XMLConfig</param-name>
        <param-value>/WEB-INF/config.xml</param-value>
    </init-param>
    <init-param>
        <param-name>debug</param-name>
        <param-value>true</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>ConnectorServlet</servlet-name>
    <url-pattern>
        /resources/ckfinder/core/connector/java/connector.java
    </url-pattern>
</servlet-mapping>

<filter>
    <filter-name>FileUploadFilter</filter-name>
    <filter-class>com.ckfinder.connector.FileUploadFilter</filter-class>
            <init-param>
                <param-name>sessionCookieName</param-name>
                <param-value>JSESSIONID</param-value>
            </init-param>
            <init-param>
                <param-name>sessionParameterName</param-name>
                <param-value>jsessionid</param-value>
            </init-param>
</filter>
<filter-mapping>
    <filter-name>FileUploadFilter</filter-name>
    <url-pattern>
        /resources/ckfinder/core/connector/java/connector.java
     </url-pattern>
</filter-mapping>

.jsp文件,您希望ckeditor和ckfinder集成到textarea

<%@ page import="com.ckeditor.CKEditorConfig" %>
<% 
    CKEditorConfig settings = new CKEditorConfig();
    settings.addConfigValue("filebrowserBrowseUrl","/myapp/resources/ckfinder/ckfinder.html");
    settings.addConfigValue("filebrowserImageBrowseUrl","/myapp/resources/ckfinder/ckfinder.html?type=Images");
    settings.addConfigValue("filebrowserFlashBrowseUrl","/myapp/resources/ckfinder/ckfinder.html?type=Flash");
    settings.addConfigValue("filebrowserUploadUrl","/myapp/resources/ckfinder/core/connector/java/connector.java?command=QuickUpload&type=Files");
    settings.addConfigValue("filebrowserImageUploadUrl","/myapp/resources/ckfinder/core/connector/java/connector.java?command=QuickUpload&type=Images");
    settings.addConfigValue("filebrowserFlashUploadUrl","/myapp/resources/ckfinder/core/connector/java/connector.java?command=QuickUpload&type=Flash");
%>

<ckeditor:replace replace="editor1" basePath="/myapp/resources/ckeditor/" config="<%=settings %>" />