gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:55:02 27 4
gpt4 key购买 nike

我正在尝试将 Atmosphere 支持添加到 Wicket-1.5.X 网络应用程序。 (目前无法升级到 6。)

我目前将 wicket 过滤器配置为在 Atmospheres MeteorServlet 之上运行。我已经为要在我的应用程序中使用的 Atmosphere 创建了一个 sharedResource。我注意到,即使使用该配置,甚至不使用共享资源的页面(如我的静态登录页面)似乎仍会激活它。

我认为解决方案是将 wicket 过滤器从 MeteorServlet 的顶部移动到它的旁边。这样/App/MyResource 将发射 meteor ,但其他所有东西都只需要 get wicket。

我该怎么做?

万一重要:

  • Tomcat 6.0.29
  • 火狐 16.0.x
  • IE 9

更新:
这是我的 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>

P.S.:也许 wicket Dev 的同胞知道,1.5 是否仍然可以用作过滤器或 servlet?

最佳答案

不知道这个具体情况,但通常它只是在框架(即 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>

关于java - 如何为特定资源使用 servlet,但为 Web 应用程序的其余部分使用 wicket,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13404523/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com