【问题标题】:Struts 2 application throws 404 exceptionStruts 2 应用程序抛出 404 异常
【发布时间】:2014-04-25 10:04:07
【问题描述】:

在我的struts 2.3.16.1应用中,web.xml中的filter映射后出现“resource not found异常”。甚至web目录下的jsp页面也出现同样的异常。 提前感谢您的帮助。

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

struts.xml

        <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts PUBLIC
       "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
       "http://struts.apache.org/dtds/struts-2.0.dtd">

    <struts>
    <package name="default" extends="struts-default">
    <action name="getTutorial" class="org.kishore.struts2.TutorialAction">
    <result>/success.jsp</result>
    </action>

    </package>

    </struts>

【问题讨论】:

  • 资源/页面返回 404 的请求?
  • 当我尝试访问 getTutorial.action.
  • 我认为它正在为&lt;result name="input"&gt;运行提供jsp页面路径

标签: java jsp struts2


【解决方案1】:

如果你的错误是

输入状态报告

消息/YourProjectName/success.jsp

说明请求的资源不可用。

那么这意味着你的success.jsp页面丢失了

如果消息为空且控制台错误为

无法加载配置。 - 动作 - 文件:/C:/Users/Parth/workspace1/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/serializ/WEB-INF/classes/struts.xml:7:75

那么你的班级org.kishore.struts2.TutorialAction.java 不见了

如果您遇到以下错误

严重:调度程序初始化失败无法加载配置。 - bean - jar:file:/F:/apache-tomcat-6.0.39/wtpwebapps/struts2starter/WEB-INF/lib/struts2-‌​portlet-plugin-2.3.16.1.jar!/struts-plugin.xml: 31:133 at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(Configurati‌​onManager.java:70)

原因:java.lang.ClassNotFoundException: javax.portlet.PortletMode

这意味着下载Portlet Api 2.0.jar,因为没有它你将无法使用struts2-‌​portlet-plugin-2.3.16.1.jar。如果您不添加Portlet Api 2.0.jar,您将继续收到错误java.lang.ClassNotFoundException: javax.portlet.PortletMode

注意:还要确保您使用与struts-core-2.x.x.jar.具有相同版本的兼容版本的jar

例如如果您使用的是struts2-core-2.2.3.jar,那么您必须使用struts2-‌​portlet-plugin-2.2,3.jar

【讨论】:

  • 我在控制台中收到以下错误严重:调度程序初始化失败无法加载配置。 - bean - jar:file:/F:/apache-tomcat-6.0.39/wtpwebapps/struts2starter/WEB-INF/lib/struts2-portlet-plugin-2.3.16.1.jar!/struts-plugin.xml:31: 133 在 com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
  • 我更新了答案。请看。如果还有更多错误发生,请告诉我。如果您是 stackoverflow 的新手,请参阅meta.stackexchange.com/questions/5234/…
  • 我正在使用 struts2-‌​portlet-plugin-2.3.16.1.jar 和 struts-core-2.3.16.1.jar 即两者是相同的版本。我仍然收到错误
  • 我在回答中添加了注意:另外下载Portlet Api 2.0.jar,因为没有它你将无法使用struts2-‌​portlet-plugin-2.3.16.1.jar
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-05-03
  • 1970-01-01
  • 2012-06-28
  • 1970-01-01
  • 2011-04-24
  • 2018-10-22
相关资源
最近更新 更多