“The Struts dispatcher cannot be found” error while deploying application on WebLogic 12.1.3

丶灬走出姿态 提交于 2019-12-17 06:54:51

问题


I have the following error while trying to run my application on 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.

This is my web.xml file :

<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>


回答1:


If you are using Struts tags inside JSP page that has listed in the welcome-file-list it should be removed.

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.

And hence without associated filter. The associated filter is defined struts2 mapped to /*. It means it should serve all requests, unless the welcome file is served by the web server.

Normally, you should not directly access JSP pages without prior action execution, that returns a dispatcher' type result. In this result you can specify the location of the JSP file you want to get the access.

The welcome-file-list files are handled by the web container if you navigate to the folder of your web content hierarchy, such as if you aren't using the .action extension in the URL, and there's a welcome-file inside it, and there's no action mapped to that URL. In this case you cannot use struts tags inside the welcome-file because you are trying to run it without associated filter, or the struts2 filter is already handled another request.




回答2:


You are using Struts tags inside a JSP, probably

/jsp/ao/ApplicationStartUp.jsp

but it has been called without passing through an Action.

Either pass through an Action, or remove Struts tags from JSP called directly.

For a welcome file, I'd go with the latter.



来源:https://stackoverflow.com/questions/31336754/the-struts-dispatcher-cannot-be-found-error-while-deploying-application-on-web

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!