我收到以下错误,我用谷歌搜索了很多,得到了许多不同类型的解决方案,但无法解决。
我的堆栈跟踪
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)
我的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>
我的目录结构
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>
我已经创建了这个项目来学习Struts,所以只想看看struts.xml到action类的映射是如何完成的
我能够成功运行localhost:8080 / TicketSystem / index.html。
但是当我运行localhost:8080 / TicketSystem / CreateTicket.action时。我收到上述错误。
请帮助我解决它。
问候,
马赫什
最佳答案
我认为这是因为尚未定义名称空间。
尝试这个。<package name="default" namespace="/" extends="struts-default">
关于java - 没有为 namespace /映射任何操作,并且操作名称为CreateTicket,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13814478/