struts2中找不到Struts调度程序

发布于 2024-12-22 19:52:42 字数 9865 浏览 5 评论 0原文

最初,当我单击提交按钮时,我的 jsp 页面以正确的方式显示,它显示 sql 库的类未找到异常,但后来我添加 mysql 库,它没有显示 jsp 页面并给出异常

org.apache.jasper.JasperException : 找不到 Struts 调度程序。这是 通常是由于使用 Struts 标签而没有关联的过滤器引起的。 Struts 标签是 仅当请求通过其初始化的 servlet 过滤器时才可用 该标签所需的 Struts 调度程序。 - [未知位置]

根本原因

找不到 Struts 调度程序。这通常是由于使用 Struts 标签而没有关联的过滤器造成的。 Struts 标签仅在请求通过其 servlet 过滤器时才可用,该过滤器会初始化该标签所需的 Struts 调度程序。

请帮我解决这个

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xmlns="http://java.sun.com/xml/ns/javaee" 
         xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
         id="WebApp_ID" 
         version="2.5">

  <display-name>Struts2Example17</display-name>
  <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>

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

这个错误也来自

SEVERE: log4j:ERROR LogMananger.repositorySelector was null likely due to error in class reloading, using NOPLoggerRepository.
SEVERE: log4j:WARN No appenders could be found for logger (com.opensymphony.xwork2.config.providers.XmlConfigurationProvider).
SEVERE: log4j:WARN Please initialize the log4j system properly.
SEVERE: WebModule[/Struts2Example17]PWC1270: Exception starting filter struts2

errortrace

SEVERE: log4j:ERROR LogMananger.repositorySelector was null likely due to error in class reloading, using NOPLoggerRepository.
SEVERE: log4j:WARN No appenders could be found for logger (com.opensymphony.xwork2.config.providers.XmlConfigurationProvider).
SEVERE: log4j:WARN Please initialize the log4j system properly.
SEVERE: WebModule[/Struts2Example17]PWC1270: Exception starting filter struts2
java.lang.InstantiationException
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:124)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4685)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:5377)
    at com.sun.enterprise.web.WebModule.start(WebModule.java:498)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2000)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1651)
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
    at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:294)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:462)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:382)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:360)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1232)
    at org.glassfish.deployment.admin.ReDeployCommand.execute(ReDeployCommand.java:126)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1232)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:459)
    at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:209)
    at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
    at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:238)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:722)
Caused by: Unable to load configuration. - bean - jar:file:/D:/strts2/Struts2Example17/build/web/WEB-INF/lib/struts2-dojo-plugin-2.1.8-sources.jar!/struts-plugin.xml:29:119
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:360)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:403)
    at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:48)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:264)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:120)
    ... 47 more
Caused by: Unable to load bean: type:org.apache.struts2.views.TagLibrary class:org.apache.struts2.dojo.views.DojoTagLibrary - bean - jar:file:/D:/strts2/Struts2Example17/build/web/WEB-INF/lib/struts2-dojo-plugin-2.1.8-sources.jar!/struts-plugin.xml:29:119
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:222)
    at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:165)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
    ... 53 more
Caused by: java.lang.ClassNotFoundException: org.apache.struts2.dojo.views.DojoTagLibrary
    at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1519)
    at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1369)
    at com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:146)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:193)
    ... 56 more

Jsp 文件

 <%-- 
        Document   : statusdonationjsp
        Created on : Dec 20, 2011, 10:34:09 PM
        Author     : bhavishya
    --%>

    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <%@taglib uri="/struts-tags" prefix="s"%>
    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>Pending Donation </title>

        </head>
        <body>

        Search String
              <s:form action="FindPendingDonation">
        <s:textfield name="detail" label="Name" />
            <s:select name="amounttype" list="{'Cash','Cheque'}" label="Paymet type" id="type" onchange="displayBlock()" />
            <s:select name="status" list="{'Paid','Unpaid'}" label="Status(Cash)" />
        <s:textfield name="amount" label="Amount" />
            <s:textfield name="responsibleparty" label="Bank Name/Responsible party"  id="cash" />
            <s:textfield name="chequeno" lable ="Cheque NO" id="chequeno"/>

            <s:submit />
    </s:form>

        </body>
    </html>

initially my jsp page is showed in proper way when i click on submit button it is showing class not found exception for sql library but then i add mysql library it is not showng jsp page and giving exception

org.apache.jasper.JasperException: 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. - [unknown location]

root cause

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.

Please help me to resolve this

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xmlns="http://java.sun.com/xml/ns/javaee" 
         xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
         id="WebApp_ID" 
         version="2.5">

  <display-name>Struts2Example17</display-name>
  <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>

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

this error is also coming

SEVERE: log4j:ERROR LogMananger.repositorySelector was null likely due to error in class reloading, using NOPLoggerRepository.
SEVERE: log4j:WARN No appenders could be found for logger (com.opensymphony.xwork2.config.providers.XmlConfigurationProvider).
SEVERE: log4j:WARN Please initialize the log4j system properly.
SEVERE: WebModule[/Struts2Example17]PWC1270: Exception starting filter struts2

errortrace

SEVERE: log4j:ERROR LogMananger.repositorySelector was null likely due to error in class reloading, using NOPLoggerRepository.
SEVERE: log4j:WARN No appenders could be found for logger (com.opensymphony.xwork2.config.providers.XmlConfigurationProvider).
SEVERE: log4j:WARN Please initialize the log4j system properly.
SEVERE: WebModule[/Struts2Example17]PWC1270: Exception starting filter struts2
java.lang.InstantiationException
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:124)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4685)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:5377)
    at com.sun.enterprise.web.WebModule.start(WebModule.java:498)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2000)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1651)
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
    at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:294)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:462)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:382)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:360)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1232)
    at org.glassfish.deployment.admin.ReDeployCommand.execute(ReDeployCommand.java:126)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1232)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:459)
    at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:209)
    at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
    at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:238)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:722)
Caused by: Unable to load configuration. - bean - jar:file:/D:/strts2/Struts2Example17/build/web/WEB-INF/lib/struts2-dojo-plugin-2.1.8-sources.jar!/struts-plugin.xml:29:119
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:360)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:403)
    at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:48)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:264)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:120)
    ... 47 more
Caused by: Unable to load bean: type:org.apache.struts2.views.TagLibrary class:org.apache.struts2.dojo.views.DojoTagLibrary - bean - jar:file:/D:/strts2/Struts2Example17/build/web/WEB-INF/lib/struts2-dojo-plugin-2.1.8-sources.jar!/struts-plugin.xml:29:119
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:222)
    at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:165)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
    ... 53 more
Caused by: java.lang.ClassNotFoundException: org.apache.struts2.dojo.views.DojoTagLibrary
    at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1519)
    at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1369)
    at com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:146)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:193)
    ... 56 more

JSp file

 <%-- 
        Document   : statusdonationjsp
        Created on : Dec 20, 2011, 10:34:09 PM
        Author     : bhavishya
    --%>

    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <%@taglib uri="/struts-tags" prefix="s"%>
    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>Pending Donation </title>

        </head>
        <body>

        Search String
              <s:form action="FindPendingDonation">
        <s:textfield name="detail" label="Name" />
            <s:select name="amounttype" list="{'Cash','Cheque'}" label="Paymet type" id="type" onchange="displayBlock()" />
            <s:select name="status" list="{'Paid','Unpaid'}" label="Status(Cash)" />
        <s:textfield name="amount" label="Amount" />
            <s:textfield name="responsibleparty" label="Bank Name/Responsible party"  id="cash" />
            <s:textfield name="chequeno" lable ="Cheque NO" id="chequeno"/>

            <s:submit />
    </s:form>

        </body>
    </html>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

笑,眼淚并存 2024-12-29 19:52:42

根据讨论,问题似乎是由于直接访问 JSP 页面而没有让 Struts2 调度程序初始化请求处理周期并创建所需的值堆栈和其他参数。

基于 Struts 或 MVC2 的架构中的最佳方法是执行 Action,即使您的操作没有为您做任何工作。

Struts2 为此提供了开箱即用的功能,如果我们没有在配置文件中提供任何操作类,Struts2 将为我们动态创建一个 Action 类,并将返回 SUCCESS 作为结果。因此我们需要在 struts 中执行以下操作。 xml 文件

<action name="myaction">
  <result>/statusdonationjsp.jsp</result>
</action>

已更新

根据新的堆栈跟踪,类路径中似乎缺少 dojo 插件。请在类路径中包含 struts2-dojo-plugin jar

As per the discussion problem seems to be due to directly accessing the JSP page and not letting the Struts2 Dispatcher to init the request processing cycle and create needed value stack and other parameters.

Best way in Struts or MVC2 based architecture is to go by Action even if your action is not doing any work for you.

Struts2 provides out of the box functionality for this, if we are not providing any action class in the configuration file Struts2 will create an Action class for us on the fly and will return SUCCESS as result.so we need to do following in our struts.xml file

<action name="myaction">
  <result>/statusdonationjsp.jsp</result>
</action>

Updated

As per the new stack-trace seems that dojo plugin in missing from the class path.Please include struts2-dojo-plugin jar in your class path

青衫负雪 2024-12-29 19:52:42

我认为你的问题是你的 web.xml 文件。

只需将旧的过滤器标签更改为新的过滤器标签并进行一次修改即可

<filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
  </filter>

,因此,它应该适用于此解决方案。但是,如果它不起作用,更好的方法是从此链接复制 struts-blank.war 文件 struts.war 。根据您这里的版本,我指的是 2.x 版本,下载 2.x 一个 rar 文件并解压它并打开它。复制 struts-balnk.war 并导入到您的 ide for 例如:eclipse 在 Web 内容下的该目录结构中复制您的 jsp 文件 100% 它会工作。

I think your problem was your web.xml file .

Just Change Your old filter tag to new one with one modification

<filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
  </filter>

So, it should work for this solution. However if it's not work, better way is just copy struts-blank.war file from this link struts.war. According to your version here i mean 2.x versions, download 2.x one rar file and extract it & in that copy struts-balnk.war and import to your ide for eg:eclipse in that directory structure under web content copy your jsp file 100% it will work.

疯了 2024-12-29 19:52:42

确保导入的 jar 具有相同的 struts2 版本。我收到此错误是因为

Struts2-Core-2.3.15.3.jar

struts2-dojo-plugin-2.3.20

我能够通过对两个 jar 使用版本 2.3.15.3 来解决这个问题。

Make sure the importing jars have the same struts2 version. I got this error because of

Struts2-Core-2.3.15.3.jar

and

struts2-dojo-plugin-2.3.20

I was able to resolve this by using version 2.3.15.3 for both jars.

暖风昔人 2024-12-29 19:52:42

此异常可能是由于 1) 在 Web.xml 中未定义过滤器或 2) 服务器未在 web.xml 中查找过滤器调度程序。只需清理项目、清理服务器并重新启动服务器即可。它会起作用的。

This Exception may be due to 1)In Web.xml filter not defined or 2)The server doesn't look up the web.xml for Filter Dispatcher. Just clean the project, clean the server and restart the server. It will work.

时光瘦了 2024-12-29 19:52:42

我面临着同样的问题。我的项目中有多个配置文件(其他文件包含在默认的 struts.xml 文件中)。
默认struts.xml中包含的文件名必须与<匹配>包名>各个包含的 xml 的数量,并且所有包含的文件不应相同。在每个包含的 xml 中提供正确的信息解决了该问题。
此链接可能很有用 - http://www.codejava。 net/frameworks/struts/splitting-modularizing-struts2-configuration-file

I was facing the same issue. I have the multiple configuration files in my project(other files are included in the default struts.xml file).
The included file names in default struts.xml must match with the < package name > of individual included xmls and should not be same for all the included files. Giving the correct in each included xmls resolved the issue.
This link can be useful - http://www.codejava.net/frameworks/struts/splitting-modularizing-struts2-configuration-file

小…楫夜泊 2024-12-29 19:52:42

请检查您的项目结构,即 web.xml 位于 WEB-INF 文件夹下,所有视图均位于 webcontent 文件夹下

Please check your project structure, i.e web.xml is under WEB-INF folder, all view is under webcontent folder

掐死时间 2024-12-29 19:52:42

我也面临同样的问题,也尝试按照上面评论中提到的方式更改jar文件,但没有解决问题。

最后,我发现我的 struts.xml 文件中的 package 标记中的 action 标记输入错误。对于 action 标记的 type 属性,我给出了成功或错误。
实际上,必须有name属性而不是type。对于用于重定向页面的type

同样在 package 标签中还有 namespace 属性,我错误地输入了 nameSpace,
由于这个原因,我面临“无法找到 Struts 调度程序”的问题。

但在我纠正错误后,它运行良好,没有问题...所以只需检查您的 struts.xml 文件。

I'm also facing the same problem, also try changing jar file as mention in above comment, but not solve the issue.

finally, i found typing mistake in my struts.xml file, for action tag in package tag. for type attribute of action tag i have given success or error.
Actually, there must be name attribute instead of type. for type used for redirect page.

also in package tag there namespace attribute and i wrongly type nameSpace,
for this reasons i'm facing "The Struts dispatcher cannot be found".

but after i correcting my mistakes it's running well no issue...so just check your struts.xml file.

若言繁花未落 2024-12-29 19:52:42

尝试将 URL 模式从 /* 更改为 *.do >。

Try changing your URL pattern from <url-pattern>/*</url-pattern> to <url-pattern>*.do</url-pattern>.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文