struts2+fckeditor冲突 -hxzon动手 -gdo

struts2+fckeditor冲突 -hxzon动手 -gdo

要上传图片必须添加fck的servlet。
net.fckeditor.connector.ConnectorServlet
文件上传到应用目录的userfiles\image下。
当加入struts2过滤器时,
不用net.fckeditor.connector.ConnectorServlet就可以上传,
但却上传到D:\big\Tomcat6.0\work\Catalina\localhost\fck2,
文件后缀为tmp。
因此图片无法显示。
当同时有struts2过滤器和net.fckeditor.connector.ConnectorServlet时,显示如下错误。
显示security error,you probably dont have enough permissions to upload.please check your server.
-------------------------------
<?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">
<context-param>
   <param-name>log4jConfigLocation</param-name>
   <param-value>/WEB-INF/log4j.properties</param-value>
</context-param>
<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>
    /fckeditor/editor/filemanager/connectors/*
   </url-pattern>
</servlet-mapping>
<!--
   <filter>
   <filter-name>struts2</filter-name>
   <filter-class>
   org.apache.struts2.dispatcher.FilterDispatcher
   </filter-class>
   </filter>
   <filter-mapping>
   <filter-name>struts2</filter-name>
   <url-pattern>/*</url-pattern>
   </filter-mapping>
-->
<welcome-file-list>
   <welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
-----------------------------------------
index.jsp
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.fckeditor.net" prefix="FCK"%>
<html>
<head>
</head><body>
   <form method="post" action="display.jsp">
    <FCK:editor instanceName="content">
     <jsp:attribute name="value"> end</jsp:attribute>
    </FCK:editor>
   </form>
</body>
</html>
------------------------------------------
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.fckeditor.net" prefix="FCK"%>
<html>
<head>
</head><body>
   <%=request.getParameter("content") %>
</body>
</html>
--------------------------------------
将fckeditor文件夹拷贝到应用目录下,classes目录下添加下面两个配置。
--------
fckeditor.properties
connector.userActionImpl=net.fckeditor.requestcycle.impl.UserActionImpl
--------
log4j.properties
#log4j.rootLogger=FATAL,stdout
#log4j.rootLogger=DEBUG,stdout
#log4j.appender.stdout=org.apache.log4j.ConsoleAppender
#log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
#log4j.appender.stdout.layout.ConversionPattern=%5p (%F:%L) - %m%nlog4j.rootLogger=ALL, SOCKETlog4j.appender.SOCKET=org.apache.log4j.net.SocketAppender
log4j.appender.SOCKET.RemoteHost=localhost
log4j.appender.SOCKET.Port=4445log4j.logger.org.apache=WARN===================================
<p><img height="56" width="100" alt="" src="/_userfiles/12564575_0.jpg" /></p>
====================================
修改struts2过滤器的映射路径,即
<filter-mapping>
   <filter-name>struts-cleanup</filter-name>
   <url-pattern>/*</url-pattern>
</filter-mapping>
<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>
可以上传图片,并且带参数的action也可以执行。
如http://localhost:8080/shbbs5/p!forumDisplay.action?forum.id=4
但听说可能会导致struts2标签不能使用。
但我在页面中使用如下标签
<s:form action="upload!upload.action" method="post"
    enctype="multipart/form-data">
<s:file name="files" />
<s:submit value="上传文件"/>
</s:form>
可以上传下载文件,没发现问题。但s:datetimepicker 不能使用。
<s:form >
<s:datetimepicker name="order.date" label="日期"
toggleType="explode" value="today" />
<s:datetimepicker name="order.date" label="日期"
displayFormat="dddd年MM月dd日" />
<s:datetimepicker name="order.date" label="日期"
displayFormat="dddd年MM月dd日" weekStartsOn="2" />
<s:datetimepicker name="start" label="选择出发日期"
type="time" value="13:00" />
</s:form>
网上说添加一个过滤路径<url-pattern>/struts/*</url-pattern>,但我并没有添加,
而是在头部添加<s:head />(自动加上JavaScript代码),前三个标签可以使用,最后一个依然无法使用。

[url]http://hi.baidu.com/hxzon/blog/item/50fa49c20cd26333e4dd3b06.html [/url]

你可能感兴趣的:(log4j,jsp,.net,struts,fckeditor)