posts - 66, comments - 12, trackbacks - 0, articles - 0

struts2 和 fckeditor 整合

Posted on 2010-06-28 14:32 cyantide 阅读(448) 评论(0)  编辑  收藏 所属分类: struts2webhtml、script
1. 需重新编写filter,继承StrutsPrepareAndExecuteFilter
 1 import java.io.IOException;
 2 
 3 import javax.servlet.FilterChain;
 4 import javax.servlet.ServletException;
 5 import javax.servlet.ServletRequest;
 6 import javax.servlet.ServletResponse;
 7 import javax.servlet.http.HttpServletRequest;
 8 
 9 import org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter;
10 
11 public class StrutsAndFckFilter extends StrutsPrepareAndExecuteFilter {
12 
13     @Override
14     public void doFilter(ServletRequest request, ServletResponse response,
15             FilterChain chain) throws IOException, ServletException {
16         
17         HttpServletRequest httpRequest=(HttpServletRequest)request;
18         
19         if("/fckeditor/editor/filemanager/connectors".equals(httpRequest.getServletPath())){
20             chain.doFilter(request, response);
21         }else{
22             super.doFilter(request, response, chain);
23         }
24     }
25 
26 }
27 
2. 在classes目录添加 fckeditor.properties 文件
   内容为 connector.userActionImpl=net.fckeditor.requestcycle.impl.EnabledUserAction

3. 修改web.xml
  
 1 <filter>
 2         <filter-name>struts2</filter-name>
 3         <filter-class>com.capinfo.cms.common.filter.StrutsAndFckFilter</filter-class>
 4     </filter>
 5 <servlet>
 6     <servlet-name>ConnectorServlet</servlet-name>
 7     <servlet-class>
 8         net.fckeditor.connector.ConnectorServlet
 9     </servlet-class>
10     <load-on-startup>1</load-on-startup>
11 </servlet>
12 
13 <servlet-mapping>
14     <servlet-name>ConnectorServlet</servlet-name>
15     <!-- Do not wrap this line otherwise Glassfish will fail to load this file -->
16     <url-pattern>/fckeditor/editor/filemanager/connectors/*</url-pattern>
17 </servlet-mapping>
综上所述之后,整合完毕


只有注册用户登录后才能发表评论。


网站导航: