简体   繁体   English

如何为特定资源使用 servlet,但对 Web 应用程序的其余部分使用 wicket

[英]How to have a servlet for a specific resource but use wicket for the rest of the web application

I'm trying to add Atmosphere support to a Wicket-1.5.X web application.我正在尝试向 Wicket-1.5.X Web 应用程序添加 Atmosphere 支持。 (Currently upgrading to 6 isn't an option.) (目前升级到 6 不是一种选择。)

I currently have the wicket filter configured to run on top of the Atmospheres MeteorServlet .我目前将 wicket 过滤器配置为在 Atmospheres MeteorServlet之上运行。 I've created an sharedResource for Atmosphere to be used in my application.我为 Atmosphere 创建了一个共享资源以在我的应用程序中使用。 I'm noticing that however with that configuration even pages(like my static login page) that don't use the shared resource still seem activate it.我注意到,但是使用该配置,甚至不使用共享资源的页面(如我的静态登录页面)似乎仍然激活它。

I think the solution is to move the wicket filter from On top of the MeteorServlet to next to it.我认为解决方案是将 wicket 过滤器从MeteorServlet顶部移动到它旁边。 so that /App/MyResource will fire meteor but everything else with just get wicket.这样 /App/MyResource 将发射流星,但其他所有东西都只是得到检票口。

How can I do that?我怎样才能做到这一点?

In Case it Matters:万一重要:

  • Tomcat 6.0.29雄猫 6.0.29
  • Firefox 16.0.x火狐 16.0.x
  • IE 9浏览器 9

UPDATE:更新:
Here is what My web.xml currently looks like:这是我的 web.xml 目前的样子:

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
                         http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
     version="2.4">

  <display-name>CSC</display-name>

  <!--
    added for Spring Wicket Hibernate compatibility
    From: http://wicketinaction.com/2009/06/wicketspringhibernate-configuration/
  -->
  <context-param>
    <!-- tells Spring to look in the Class Path for applicationContext.xml -->
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
  </context-param>

  <listener>
    <!-- Starts Spring -->
    <listener-class>
      org.springframework.web.context.ContextLoaderListener
    </listener-class>
  </listener>

  <!-- prevent hibernate LazyLoadingException -->
  <filter>
    <filter-name>openSessionInView</filter-name>
    <filter-class> 
      org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
    </filter-class>
    <init-param>
      <param-name>SessionFactoryBeanName</param-name>
      <param-value>sessionFactory</param-value>
    </init-param>
    <init-param>
      <param-name>applicationFactoryClassName</param-name>
      <param-value>org.apache.wicket.SpringWebApplicationFactory</param-value>
    </init-param>
    <init-param>
      <param-name>applicationBean</param-name>
      <param-value>wicketApplication</param-value>
     </init-param>
     <init-param>
       <param-name>applicationClassName</param-name>
       <param-value>
         us.ak.state.revenue.cssd.Personnel.QuickStartApplication
       </param-value>
     </init-param>
     <init-param>
       <param-name>configuration</param-name>
       <param-value>deployment</param-value>
     </init-param>
     <init-param>
       <param-name>contextpath</param-name>
       <param-value>CSC</param-value>
     </init-param>
     <init-param>
       <param-name>fileEncoding</param-name>
       <param-value>ISO-8859-1</param-value>
     </init-param>
   </filter>   

   <!--Atmosphere support, to remove the Ajax Updating Bug CSC-2 -->
   <servlet>
     <description>MeteorServlet</description>
     <servlet-name>CSC</servlet-name>
     <servlet-class>org.atmosphere.cpr.MeteorServlet</servlet-class>         
     <init-param>
       <param-name>org.atmosphere.filter</param-name>
       <param-value>org.apache.wicket.protocol.http.WicketFilter</param-value>
     </init-param>
     <!-- directory settings -->
     <init-param>
       <param-name>org.atmosphere.cpr.AtmosphereHandler.contextRoot</param-name>
       <param-value>CSC</param-value>
     </init-param>
     <!-- Abilities -->
     <init-param>
        <param-name>org.atmosphere.useWebSocket</param-name>
        <param-value>true</param-value>
      </init-param>
      <init-param>
        <param-name>org.atmosphere.useNative</param-name>
        <param-value>true</param-value>
      </init-param>
      <init-param>
       <param-name>org.atmosphere.cpr.sessionSupport</param-name>
       <param-value>true</param-value>
     </init-param>
     <!-- let Atmosphere handle keep alive,
          make sure broadcast happens AFTER AJAX stuff -->
      <init-param>
        <param-name>
          org.atmosphere.cpr.AtmosphereInterceptor
        </param-name>
        <param-value>
          org.atmosphere.interceptor.AtmosphereResourceLifecycleInterceptor,
          org.atmosphere.interceptor.BroadcastOnPostAtmosphereInterceptor
        </param-value>
      </init-param>
      <!-- shouldn't this be defaultContentType? sets Content-Type header default -->
      <init-param>
        <param-name>org.atmosphere.cpr.defaultContextType</param-name>
        <param-value>text/plain</param-value>
      </init-param>
      <init-param>
        <param-name>filterMappingUrlPattern</param-name>
        <param-value>/*</param-value>
      </init-param>
      <!-- minimize memory share broadcaster -->
      <init-param>
        <param-name>org.atmosphere.cpr.broadcaster.shareableThreadPool</param-name>
        <param-value>true</param-value>
      </init-param>
      <!-- error recovery -->
      <init-param>
        <param-name>
          org.atmosphere.cpr.recoverFromDestroyedBroadcaster
        </param-name>
        <param-value>true</param-value>
      </init-param>

      <!-- wicket filter settings -->
      <init-param>
        <param-name>applicationFactoryClassName</param-name>
        <param-value>org.apache.wicket.spring.SpringWebApplicationFactory</param-value>
      </init-param>
      <init-param>
        <param-name>applicationBean</param-name>
        <param-value>wicketApplication</param-value>
      </init-param>
      <init-param>
        <param-name>applicationClassName</param-name>
        <param-value>us.ak.state.revenue.cssd.QuickStartApplication</param-value>
      </init-param>
      <init-param>
        <param-name>configuration</param-name>
        <param-value>deployment</param-value>
      </init-param>
      <init-param>
        <param-name>contextpath</param-name>
        <param-value>CSC</param-value>
      </init-param>
      <init-param>
        <param-name>fileEncoding</param-name>
        <param-value>ISO-8859-1</param-value>
      </init-param>
      <load-on-startup>0</load-on-startup>
    </servlet>

    <servlet-mapping>
      <servlet-name>CSC</servlet-name>
      <url-pattern>/*</url-pattern>
    </servlet-mapping>

    <filter-mapping>
      <filter-name>openSessionInView</filter-name>
      <url-pattern>/*</url-pattern>
    </filter-mapping>

    <mime-mapping>
      <extension>ico</extension>
      <mime-type>image/x-icon</mime-type>
  </mime-mapping>
</web-app>

PS: Maybe a fellow wicket Dev knows, does 1.5 still work as a filter or a servlet? PS:也许 wicket Dev 的同事知道,1.5 仍然可以作为过滤器或 servlet 工作吗?

Dunno about this specific case, but typically it's just a matter of adding a definition and mapping to web.xml before the framework (ie Wicket) mapping:不知道这个特定情况,但通常只是在框架(即 Wicket)映射之前添加定义和映射到 web.xml 的问题:

<servlet>
        <servlet-name>myservlet</servlet-name>
        <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
        <servlet-name>myservlet</servlet-name>
        <url-pattern>/mystuff</url-pattern>
</servlet-mapping>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM