簡體   English   中英

Weblogic 10.3.6與自定義Servlet過濾器有關的問題

[英]Weblogic 10.3.6 Issue with Custom Servlet Filters

我正在使用struts-hibernate項目,並且已成功部署在多個Web應用程序服務器中,例如Tomcat,JBoss,WAS等。

在WebLogic 10.3.6服務器中部署相同的應用程序時,這是一個奇怪的問題。

我在web.xml中沒有幾個過濾器來處理動作類之前的請求。 這些過濾器會在應用程序加載時進行初始化(調試會在init方法中進行),當我點擊URL時,它應該首先進入“我的過濾器類”的doFilter方法,但在使用weblogic的情況下,它將無法正常工作。

在其他Web應用程序服務器中也是如此。

在web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>

    <!DOCTYPE web-app PUBLIC
          "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
          "http://java.sun.com/dtd/web-app_2_3.dtd">

    <web-app>

  <!-- Parameter for JSTL resource bundle usage. -->
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>app_resources</param-value>
  </context-param>

  <!-- Parameters related to application configuration. -->
  <context-param>
    <param-name>configFile</param-name>
    <param-value>/WEB-INF/app-config.xml</param-value>
  </context-param>
  <context-param>
    <param-name>configClass</param-name>
    <param-value>org.apache.struts.apps.ajaxchat.AjaxChatConfig</param-value>
  </context-param>


    <filter>
        <filter-name>
            Logging Filter
        </filter-name>
        <description>
            Filter used to log each user action
        </description>
        <filter-class>
            com.mypackage.ActivityLoggingFilter
        </filter-class>
    </filter>

    <!-- Use this if you want db authentication -->
    <filter>
        <filter-name>
            AuthFilter
        </filter-name>
        <description>
            Filter handling custom user authentication
        </description>
        <filter-class>
            com.mypackage.AuthenticationFilter
        </filter-class>
        <init-param>
            <param-name>auth_uri</param-name>
            <param-value>/Login.do</param-value>
        </init-param>
        <init-param>
            <param-name>password_change_uri</param-name>
            <param-value>/PasChangeExp.do</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>AuthFilter</filter-name>
        <servlet-name>action</servlet-name>
    </filter-mapping>
    <filter-mapping>
        <filter-name>AuthFilter</filter-name>
        <servlet-name>tcode</servlet-name>
    </filter-mapping>
    <filter-mapping>
        <filter-name>AuthFilter</filter-name>
        <servlet-name>help</servlet-name>
    </filter-mapping>

    <!-- Map the filter to a Servlet or URL -->

    <filter-mapping>
        <filter-name>Logging Filter</filter-name>
        <servlet-name>action</servlet-name>
    </filter-mapping>

    <!-- Listeners -->
    <!--
    <listener>
        <listener-class>com.mypackage.HibernateListener</listener-class>
    </listener>
    -->
    <listener>
        <listener-class>
            com.mypackage.SessionListener
        </listener-class>
    </listener>
    <listener>
      <listener-class>com.mypackage.ContextListener</listener-class>
    </listener>

  <listener>
    <listener-class>javawebparts.listener.AppConfigContextListener</listener-class>
  </listener>

    <servlet>
        <servlet-name>Log4JInitServlet</servlet-name>
        <servlet-class>com.mypackage.Log4JInitServlet</servlet-class>
        <init-param>
            <param-name>log4j-properties-location</param-name>
            <param-value>/WEB-INF/classes/logging.properties</param-value>
        </init-param>

        <load-on-startup>1</load-on-startup>
    </servlet>


    <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>com.mypackage.InheritanceActionServet</servlet-class>

        <init-param>
            <param-name>config</param-name>
            <param-value>/WEB-INF/modules/main/config/struts-config.xml</param-value>
        </init-param>
        <init-param>
            <param-name>config/main/user</param-name>
            <param-value>/WEB-INF/modules/main/modules/user/config/struts-config.xml</param-value>
        </init-param>
        <init-param>
            <param-name>config/main/group</param-name>
            <param-value>/WEB-INF/modules/main/modules/group/config/struts-config.xml</param-value>
        </init-param>
        <init-param>
            <param-name>config/main/profile</param-name>
            <param-value>/WEB-INF/modules/main/modules/profile/config/struts-config.xml</param-value>
        </init-param>

        <load-on-startup>3</load-on-startup>
    </servlet>

    <servlet>
        <servlet-name>MenuInitServlet</servlet-name>
        <servlet-class>com.mypackage.MenuInitServlet</servlet-class>
         <load-on-startup>4</load-on-startup>
    </servlet>

    <servlet>
        <servlet-name>JnlpDownloadServlet</servlet-name>
        <servlet-class>com.sun.javaws.servlet.JnlpDownloadServlet</servlet-class>
    </servlet>

    <servlet>
        <servlet-name>tcode</servlet-name>
        <servlet-class>com.mypackage.TcodeServiceImpl</servlet-class>
    </servlet>

    <servlet>
        <servlet-name>help</servlet-name>
        <servlet-class>com.mypackage.HelpServlet</servlet-class>
    </servlet>

    <!-- servlet-mapping>
        <servlet-name>JnlpDownloadServlet</servlet-name>
        <url-pattern>*.jnlp</url-pattern>
    </servlet-mapping -->

    <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>

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

    <servlet-mapping>
        <servlet-name>help</servlet-name>
        <url-pattern>/static/help/*</url-pattern>
    </servlet-mapping>

    <session-config>
            <session-timeout>15</session-timeout>
    </session-config>

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <error-page>
      <error-code>400</error-code>
      <location>/ErrorPage.do</location>
    </error-page>

    <error-page>
      <error-code>404</error-code>
      <location>/ErrorPage404.do</location>
    </error-page>

    <error-page>
      <error-code>500</error-code>
      <location>/ErrorPage500.do</location>
    </error-page>

    <taglib>
        <taglib-uri>/tags/struts-bean</taglib-uri>
        <taglib-location>/WEB-INF/tlds/struts-bean.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>/tags/struts-html</taglib-uri>
        <taglib-location>/WEB-INF/tlds/struts-html.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>/tags/struts-logic</taglib-uri>
        <taglib-location>/WEB-INF/tlds/struts-logic.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>/tags/struts-tiles</taglib-uri>
        <taglib-location>/WEB-INF/tlds/struts-tiles.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>/tags/struts-nested</taglib-uri>
        <taglib-location>/WEB-INF/tlds/struts-nested.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>/tags/menu</taglib-uri>
        <taglib-location>/WEB-INF/tlds/menu.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>/tags/navigator</taglib-uri>
        <taglib-location>/WEB-INF/tlds/navigator.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>/tags/list</taglib-uri>
        <taglib-location>/WEB-INF/tlds/list.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>/tags/table</taglib-uri>
        <taglib-location>/WEB-INF/tlds/table.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>/tags/monitor</taglib-uri>
        <taglib-location>/WEB-INF/tlds/client.tld</taglib-location>
    </taglib>
       <taglib>
        <taglib-uri>/tags/alerts</taglib-uri>
        <taglib-location>/WEB-INF/tlds/alerts.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>/tags/custom</taglib-uri>
        <taglib-location>/WEB-INF/tlds/customFields.tld</taglib-location>
    </taglib>
    <taglib>
     <taglib-uri>/tags/filter</taglib-uri>
        <taglib-location>/WEB-INF/tlds/filter.tld</taglib-location>
    </taglib>
    <taglib>
     <taglib-uri>/tags/selectChoices</taglib-uri>
        <taglib-location>/WEB-INF/tlds/selectChoices.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>/tags/matrix</taglib-uri>
        <taglib-location>/WEB-INF/tlds/matrix.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>/tags/report</taglib-uri>
        <taglib-location>/WEB-INF/tlds/report.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>/tags/listWithActionTag</taglib-uri>
        <taglib-location>/WEB-INF/tlds/listWithActionTag.tld</taglib-location>
    </taglib>

    <!-- resource -->
    <!--resource-ref>
        <res-ref-name>jdbc/prototype</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref-->

</web-app>

weblogic.xml中

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app" 
    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 http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">
    <context-root>mps</context-root>
    <container-descriptor>
        <prefer-web-inf-classes>true</prefer-web-inf-classes>
        <show-archived-real-path-enabled>true</show-archived-real-path-enabled>
    </container-descriptor>
</weblogic-web-app>

我發現在擴展Filter類時,需要在filter類方法上方添加@Override批注。 添加此內容解決了我的問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM