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

佐手、 提交于 2019-12-13 04:48:02

问题


I am getting the below error, I have googled lot and got many different types of solutions but not able to resolve it.

My Stacktrace

    SEVERE: Could not find action or result
There is no Action mapped for namespace / and action name CreateTicket. - [unknown location]
    at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:186)
    at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:41)
    at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:494)
    at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:873)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
    at java.lang.Thread.run(Thread.java:595)

My 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>
    <constant name="struts.devMode" value="true" />
    <constant name="struts.multipart.maxSize" value="20480000" />
    <constant name="struts.enable.DynamicMethodInvocation" value="false" />

    <package name="default" extends="struts-default">
        <action name="CreateTicket" class="com.ticketservice.CreateTicket">
            <result name="success">Welcome.jsp</result>
            <result name="error">Login.jsp</result>
        </action>


    </package>
</struts> 

My Directory Structure

CreateTicket.java

package com.ticketservice;

import com.opensymphony.xwork2.ActionSupport;

public class CreateTicket extends ActionSupport {

    public String execute() {

       return "success";
    }
}

Welcome.jsp

<p>done</p>

Login.jsp

<p>not done</p>

I have create this project to learn Struts so only wanted to see how mapping of struts.xml to action class done

I am successfully able to run localhost:8080/TicketSystem/index.html.
But when I run localhost:8080/TicketSystem/CreateTicket.action. I got the above error..

Kindly help me to resolve it.

Regards, Mahesh


回答1:


I think it's because you haven't defined the namespace.

Try this.

<package name="default" namespace="/" extends="struts-default">




回答2:


The reason I was getting this error was my build path. My build path was set to other directory not at WEB-INF classes. Doing this change, solved my problem.




回答3:


may be you have make mistake into the struts.xml file. so there is some several ways to config xml file here the example.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
    <package name="default" extends="struts-default">
        <action name="helloWorld" class="controller.HelloWorld">
            <result name="success">/HelloWorld.jsp</result>

        </action>
    </package>
</struts>    

so and if you do this in this way just make sure that you have to call action from the jsp by Action name only u do not need to write .action that will cause error. that could be desired answer for your question.

i am sure that will work.



来源:https://stackoverflow.com/questions/13814478/there-is-no-action-mapped-for-namespace-and-action-name-createticket

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