ssh&ckfinder&ckeditor struts2与servlet并存解决方法

来源:互联网 发布:阿里云那个机房好 编辑:程序博客网 时间:2024/05/05 22:49

相信有很多人遇到过struts2与servlet并存的问题,近日在整合ckeditor与ckfinder的过程中就遇到了这个问题,ckfinder与ckfinder整合成功,但移入ssh框架中就出现了问题,在网上看了很多前辈的帖子,终于发现了问题所在,就是web.xml文件配置问题。经历过程如下:

通过参考这篇文章http://www.cppblog.com/fenglin/articles/147374.html

1.修改web.xml文件

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
换成

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>

这样的确是可以使用自己定义的servlet了,但是,过了不久,又出了问题,如果使用struts2标签,该jsp页面显示不出来,报错,有人说添加

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>

这样jsp页面显示成功,但是我用的datetimepicker还是显示不出来,这让我相当纠结。最终还是要解决 struts2与servlet并存问题

2.

struts2与servlet并存问题,参考http://hi.baidu.com/xsl2007/blog/item/4eb796cf94e35f0992457e11.html

问题解决,即定义一个过滤器,将servlet过滤,使struts2的核心控制器对servlet

不起作用。

下面是我的web.xml文件配置,ReDispatcherFilter类不变
<?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>index.jsp</welcome-file></welcome-file-list><filter><filter-name>MyServlet</filter-name><filter-class>com.manager.action.ReDispatcherFilter</filter-class><init-param><param-name>includeServlets</param-name><param-value>connector.java</param-value></init-param></filter><filter-mapping><filter-name>MyServlet</filter-name><url-pattern>/*</url-pattern></filter-mapping><!-- struts2 --><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>/*</url-pattern></filter-mapping><!-- ckfinder --><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>false</param-value></init-param><load-on-startup>1</load-on-startup></servlet><servlet-mapping><servlet-name>ConnectorServlet</servlet-name><url-pattern>/ckfinder/core/connector/java/connector.java</url-pattern></servlet-mapping><session-config><session-timeout>10</session-timeout></session-config><!--ckeditor  --><servlet><description>This is the description of my J2EE component</description><display-name>This is the display name of my J2EE component</display-name><servlet-name>Editor</servlet-name><servlet-class>com.ckeditor.Editor</servlet-class></servlet><servlet-mapping><servlet-name>Editor</servlet-name><url-pattern>/servlet/Editor</url-pattern></servlet-mapping><!-- spring --><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener></web-app>



总算是把这个问题解决了,有点收获,休息一下


原创粉丝点击