There is no Action mapped for namespace [/] and action name [hello2] associated with context path [/

 There is no Action mapped for namespace [/] and action name [hello2] associated with context path [/Struts2_0723].

 

    最近在看马士兵的视频学三大框架中的struts,我的版本是struts-2.3.16.1。在配置struts.xml中,我照着视频添加了<constant name="struts.devMode"value="true" />,可是tomcat还是无法自动加载,访问时会报错。错误如下:

解决方法如下:

1、 <constantname="struts.configuration.xml.reload" value="true"/>替换掉<constant name="struts.devMode"value="true" />

  <constant name="struts.devMode" value="true"/>  value="true"时表示现在处于开发模式下使用,这样可以打印出更详细的错误信息  

 <constant name="struts.configuration.xml.reload"value="true" />  的含义为当struts的配置文件修改后,系统是否自动重新加载该文件,默认值为false(生产环境下使用),开发阶段最好打开。

struts.xml如下:

<strong><span style="font-size:24px;"><?xmlversion="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
 "-//Apache Software Foundation//DTD Struts Configuration2.3//EN"
 "http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>

   <!-- Add packages here -->
      
       <constantname="struts.configuration.xml.reload" value="true"/>
      
       <!--
        <constant name="struts.devMode"value="true" />
        配置常量  value为true,表示处于开发模式struts.devMode  (不过在struts-2.3.16.1的版本下没有什么效果,
        只好用<constantname="struts.configuration.xml.reload" value="true"/>
       其含义为 当struts的配置文件修改后,系统是否自动重新加载该文件,默认值为false(生产环境下使用),开发阶段最好打开      
        )-->
    <package name="default" namespace="/"extends="struts-default">
        <actionname="hello-wo">
           <result>
             /hello.jsp
           </result>
        </action>   
    </package>

</struts>
</span></strong>


 

2、是网上百度的吐舌头,表示说会出错的原因是因为tomcat的安装路径含有空格如(C:\ProgramFiles\apache-tomcat-7.0.54),将tomcat放在没有空格的文件夹下就可以了,原理表示不清楚。

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值