java - 在 WebLogic 12.1.3 上部署应用程序时出现 "The Struts dispatcher cannot be found"错误

标签 java tomcat struts2 web.xml weblogic12c

尝试在 WebLogic 12.1.3 上运行我的应用程序时出现以下错误。

The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag.

这是我的 web.xml 文件:

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:web="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<display-name>SybUI</display-name>
<!-- location of log4j config file -->
<!-- <context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>/WEB-INF/classes/log4j2.xml</param-value>
</context-param> -->

<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>/*</url-pattern>
</filter-mapping>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
 <listener>
    <listener-class>
        org.springframework.web.util.Log4jConfigListener
    </listener-class>
</listener>
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener
    </listener-class>
</listener>
<listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener
    </listener-class>
</listener>
<!-- <filter>
    <filter-name>SessionFilter</filter-name>
    <filter-class>com.syb.core.filter.SessionFilter</filter-class>
    <init-param>
        <param-name>avoid-urls</param-name>
        <param-value>/timeOut,/pages/timeOut.jsp,/test,/pages/test.jsp,/testMsg.action,/pages/invalidToken.jsp,/login.jsp,/logoutUser,/loginUser.action,
            /common/postloginheader.html,/js/jquery.mobile.custom.min.js,/images/plus_cyn_40.png,/js/custom.js,/css/bootstrap.min.css,/css/aos-style.css,
            /css/style.css,/js/bootstrap.min.js,/js/modernizr.min.js,/css/custom.css,/js/jquery.validate.min.js,/js/respond.min.js,/js/session1.js,/js/aos-custom.js,
            /images/wres009899.png,/images/fdic.png,/images/header_1024.jpg,/images/blue-arrow.png
        </param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>SessionFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>-->
    <!--<session-config>
    <session-timeout>10</session-timeout>
</session-config> -->

<welcome-file-list>
    <welcome-file>/jsp/ao/ApplicationStartUp.jsp</welcome-file>
</welcome-file-list>

<error-page>
    <error-code>404</error-code>
    <location>/jsp/common/error/Error-PageNotFound.jsp</location>
</error-page>

<error-page>
    <exception-type>java.lang.Throwable</exception-type>
    <location>/jsp/common/error/Error-PageNotFound.jsp</location>
</error-page>

最佳答案

如果您在 welcome-file-list 中列出的 JSP 页面中使用 Struts 标记,则应将其删除。

welcome-file-list in web.xml :

The welcome-file-list element of web-app, is used to define a list of welcome files. Its sub element is welcome-file that is used to define the welcome file.

A welcome file is the file that is invoked automatically by the server, if you don't specify any file name.

因此没有关联的过滤器。关联的过滤器定义为 struts2 映射到 /*。这意味着它应该为所有请求提供服务,除非 Web 服务器提供欢迎文件。

通常情况下,您不应该直接访问 JSP 页面而无需事先执行操作,返回 dispatcher' 类型的结果。在此结果中,您可以指定要访问的 JSP 文件的位置。

welcome-file-list 如果您导航到您的 web 内容层次结构的文件夹,则文件由 web 容器处理,例如,如果您没有使用 .action 扩展名,其中有一个 welcome-file,并且没有映射到该 URL 的操作。在这种情况下,您不能在 welcome-file 中使用 struts 标记,因为您试图在没有关联过滤器的情况下运行它,或者 struts2 过滤器已经处理了另一个请求。

关于java - 在 WebLogic 12.1.3 上部署应用程序时出现 "The Struts dispatcher cannot be found"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31336754/

相关文章:

java - 使用聚合代替嵌套的 for 循环

java - object.super() 的作用是什么?如何创建国家?

java - Tomcat控制台日志到文件

java - struts属性获取属性

tomcat - 如何验证Struts2中的单选按钮

java - 如何使用 owlapi 5.1 检索 OWL 类的子类?

java - 如何使用包含完全相同类型的参数但使用其他类型参数化的参数列表的方法重载方法

java - 我应该如何处理具有许多无效 URL 的代理 HTTP 请求

Tomcat conf 文件夹位置更改?

java - struts 2文件上传没有这样的方法异常