There is no Action mapped for namespace / and action name tutorial

后端 未结 5 1692
粉色の甜心
粉色の甜心 2021-01-27 07:22

I am unable to execute my struts2 application. I am using eclipse indigo IDE, tomcat 7 and jdk 1.7.

The jar files I included are:

  • commons-logging-1.0.4.jar
相关标签:
5条回答
  • 2021-01-27 07:51

    Try to add namespace attribute into you package element of struts.xml file.

    Like this:

    <struts>
    <package name="default" extends="struts-default" namespace="/">
        <action name="tutorial" class="com.test.TutorialAction">
            <result name="success">/success.jsp</result>
            <result name="failure">/failure.jsp</result>
        </action>
    </package>
    </struts>
    
    0 讨论(0)
  • 2021-01-27 07:56

    As others have pointed out, you do not have a getTutorial action in your mapping, only a "tutorial". However, I'm going to skip over that and suggest that you learn how to sanity check a Struts2 app. Anytime you are setting up a new technology, and even when you are working with a familiar technology, it is very useful to understand how to do a basic sanity check -- in this case, you need to verify that your struts xml has been successfully parsed and the framework knows about your actions.

    I HIGHLY RECOMMEND you add the Struts 2 Config Browser plugin to your struts 2 apps. To add the plugin, you just get the jar ( all struts 2 plugins are jars ) and put in your webapp's lib directory. That's it. When you start your applicaiton, hit this URL:

    http://localhost:8080/starter/config-browser/index.action
    

    And it shows you all of the actions, as well as other configurations, that the framework knows about. Essentialy struts 2 diagnostic tool, and too easy to use to not use it.

    0 讨论(0)
  • 2021-01-27 08:00

    I had the same problem and I saw multiple posts on this one....here is the possible solution

    I was pretty sure that I had mapped all my actions accurately, but it was showing the same error above....so I just cleaned the project and then ran it again..it worked perfectly fine...give it a try !

    I encountered this so many times...so to avoid such kind of things, I just added "../eclipse.exe -clean" to the shortcut icon property....this works and u can forget about getting such kind of errors which is actually not an error....!

    0 讨论(0)
  • 2021-01-27 08:07

    The error comes because the server is not able to find correct path for struts.xml . Its better to put the struts.xml in parallel to src folder or in WEB-INF/classes.

    0 讨论(0)
  • 2021-01-27 08:14

    Try this once don't append .action

    <form action="tutorial">
    

    place your struts.xml file in src outside the package or in WEB-INF classes folder.

    0 讨论(0)
提交回复
热议问题