• struts2中错误There is no Action mapped for namespace [/] and action name [] associated with context path


     


    1
    There is no Action mapped for namespace [/] and action name [] associated with context path [/Struts2_0300_Action2]. - [unknown location] 2 at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185) 3 at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63) 4 at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:37) 5 at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58) 6 at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:554) 7 at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:81) 8 at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99) 9 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) 10 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 11 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218) 12 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) 13 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) 14 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) 15 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) 16 at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) 17 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) 18 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442) 19 at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1083) 20 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:640) 21 at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) 22 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 23 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 24 at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 25 at java.lang.Thread.run(Thread.java:745)

    Struts问题确实让我很烦啊,调好了这个bug,出现下面这个bug,这个有事刚刚弄了一下午的问题。

    查找了许多答案,

    大致的解决方法如下

    1:注意Struts.xml文件的位置,必须在src目录之下

    2:

    1 <!DOCTYPE struts PUBLIC
    2     "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    3     "http://struts.apache.org/dtds/struts-2.3.dtd">

    这里面的Struts—2.3.dtd必须与自己的tomcat版本相一致。

    3:

    1 <struts>
    2     <constant name="struts.devMode" value="true" />
    3     <package name="exercise"  extends="struts-default"  namespace="/" >

    在struts文件中开发模式必须默认为true

    最后发现虽然我的struts.xml文件位于src文件之下,但是

    struts.xm位于src下是为了编译后能找到struts配置文件,必须确保其在WEB-INF之下

    更改eclipse web 项目默认编译输出路径:

    eclipse中只能针对项目更改,因为其默认的是build目录下的,只能以项目更改: 
    项目右键 -》properties -》Java Build Path -》source -》Default output folder,选择你的路径,ok!

    最后有个方法,如果找不到对应的可以直接在后面加上自己Action的名字

  • 相关阅读:
    Java Web 项目学习(二) 发送邮件
    Java Web 项目学习(一) 项目调试与版本控制
    org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: A query was run and no Result Maps were found for the Mapped Statement
    拓扑排序
    Java中的<< 和 >> 和 >>>
    Java Web 项目学习(一) Spring MVC 入门
    Java Web 项目学习(一) Spring 入门
    oracleDBA-D1
    Linux运维(3年以内)
    数据库DBA(3年以内需求)
  • 原文地址:https://www.cnblogs.com/xiaxj/p/6024156.html
Copyright © 2020-2023  润新知